From d5e1edae9fd3225155562e2d580549339a61fff6 Mon Sep 17 00:00:00 2001 From: dreis2211 Date: Sun, 15 Aug 2021 12:48:04 +0200 Subject: [PATCH] Use Pattern for Groovy closure checks See gh-27661 --- .../org/springframework/boot/BeanDefinitionLoader.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java index 93fdf1658f..b59ec87f84 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2020 the original author or authors. + * Copyright 2012-2021 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. @@ -20,6 +20,7 @@ import java.io.IOException; import java.lang.reflect.Constructor; import java.util.HashSet; import java.util.Set; +import java.util.regex.Pattern; import groovy.lang.Closure; @@ -63,6 +64,8 @@ class BeanDefinitionLoader { // Static final field to facilitate code removal by Graal private static final boolean XML_ENABLED = !SpringProperties.getFlag("spring.xml.ignore"); + private static final Pattern GROOVY_CLOSURE_PATTERN = Pattern.compile(".*\\$_.*closure.*"); + private final Object[] sources; private final AnnotatedBeanDefinitionReader annotatedReader; @@ -296,7 +299,7 @@ class BeanDefinitionLoader { } private boolean isGroovyClosure(Class type) { - return type.getName().matches(".*\\$_.*closure.*"); + return GROOVY_CLOSURE_PATTERN.matcher(type.getName()).matches(); } private boolean hasNoConstructors(Class type) {