Skip to content

Commit d5e1eda

Browse files
dreis2211snicoll
authored andcommitted
Use Pattern for Groovy closure checks
See gh-27661
1 parent dceaa6a commit d5e1eda

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
2020
import java.lang.reflect.Constructor;
2121
import java.util.HashSet;
2222
import java.util.Set;
23+
import java.util.regex.Pattern;
2324

2425
import groovy.lang.Closure;
2526

@@ -63,6 +64,8 @@ class BeanDefinitionLoader {
6364
// Static final field to facilitate code removal by Graal
6465
private static final boolean XML_ENABLED = !SpringProperties.getFlag("spring.xml.ignore");
6566

67+
private static final Pattern GROOVY_CLOSURE_PATTERN = Pattern.compile(".*\\$_.*closure.*");
68+
6669
private final Object[] sources;
6770

6871
private final AnnotatedBeanDefinitionReader annotatedReader;
@@ -296,7 +299,7 @@ private boolean isEligible(Class<?> type) {
296299
}
297300

298301
private boolean isGroovyClosure(Class<?> type) {
299-
return type.getName().matches(".*\\$_.*closure.*");
302+
return GROOVY_CLOSURE_PATTERN.matcher(type.getName()).matches();
300303
}
301304

302305
private boolean hasNoConstructors(Class<?> type) {

0 commit comments

Comments
 (0)