diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilter.java index 7cc3ec12c5..4e52f29b95 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,8 +46,8 @@ abstract class NamePatternFilter { } public Map getResults(String name) { - Pattern pattern = getRegexPattern(name); - if (pattern == null) { // this is not a regex + Pattern pattern = compilePatternIfNecessary(name); + if (pattern == null) { Object value = getValue(this.source, name); Map result = new HashMap(); result.put(name, value); @@ -60,13 +60,13 @@ abstract class NamePatternFilter { } - private Pattern getRegexPattern(String name) { + private Pattern compilePatternIfNecessary(String name) { for (String part : REGEX_PARTS) { if (name.contains(part)) { try { return Pattern.compile(name); } - catch (PatternSyntaxException e) { + catch (PatternSyntaxException ex) { return null; } } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilterTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilterTests.java index 3ed021000d..582c973444 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilterTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/NamePatternFilterTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.