diff --git a/spring-core/src/main/java/org/springframework/aot/hint/ResourceHintsPredicates.java b/spring-core/src/main/java/org/springframework/aot/hint/ResourceHintsPredicates.java index 6de4d64979..b31da9ed08 100644 --- a/spring-core/src/main/java/org/springframework/aot/hint/ResourceHintsPredicates.java +++ b/spring-core/src/main/java/org/springframework/aot/hint/ResourceHintsPredicates.java @@ -30,7 +30,7 @@ import org.springframework.util.ConcurrentLruCache; */ public class ResourceHintsPredicates { - private static final ConcurrentLruCache CACHED_RESOURCE_PATTERNS = new ConcurrentLruCache<>(32, Pattern::compile); + private static final ConcurrentLruCache CACHED_RESOURCE_PATTERNS = new ConcurrentLruCache<>(32, ResourcePatternHint::toRegex); ResourceHintsPredicates() { } @@ -80,12 +80,12 @@ public class ResourceHintsPredicates { return hints -> hints.resources().resourcePatterns().reduce(ResourcePatternHints::merge) .map(hint -> { boolean isExcluded = hint.getExcludes().stream() - .anyMatch(excluded -> CACHED_RESOURCE_PATTERNS.get(excluded.getPattern()).matcher(resourceName).matches()); + .anyMatch(excluded -> CACHED_RESOURCE_PATTERNS.get(excluded).matcher(resourceName).matches()); if (isExcluded) { return false; } return hint.getIncludes().stream() - .anyMatch(included -> CACHED_RESOURCE_PATTERNS.get(included.getPattern()).matcher(resourceName).matches()); + .anyMatch(included -> CACHED_RESOURCE_PATTERNS.get(included).matcher(resourceName).matches()); }).orElse(false); } diff --git a/spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsPredicatesTests.java b/spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsPredicatesTests.java index 8b38a0fc6d..ac3f607d5c 100644 --- a/spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsPredicatesTests.java +++ b/spring-core/src/test/java/org/springframework/aot/hint/ResourceHintsPredicatesTests.java @@ -42,7 +42,7 @@ class ResourceHintsPredicatesTests { @Test void resourcePatternMatchesResourceName() { - this.runtimeHints.resources().registerPattern("/test/spring.*"); + this.runtimeHints.resources().registerPattern("/test/*"); assertPredicateMatches(resources.forResource("/test/spring.properties")); }