Skip to content

Commit 5cb950d

Browse files
committed
Support for shared GroovyClassLoader in GroovyScriptFactory
Closes spring-projectsgh-25177
1 parent 4b78903 commit 5cb950d

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

spring-context/src/main/java/org/springframework/scripting/groovy/GroovyScriptFactory.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2020 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.
@@ -158,7 +158,14 @@ public void setBeanFactory(BeanFactory beanFactory) {
158158

159159
@Override
160160
public void setBeanClassLoader(ClassLoader classLoader) {
161-
this.groovyClassLoader = buildGroovyClassLoader(classLoader);
161+
if (classLoader instanceof GroovyClassLoader &&
162+
(this.compilerConfiguration == null ||
163+
((GroovyClassLoader) classLoader).hasCompatibleConfiguration(this.compilerConfiguration))) {
164+
this.groovyClassLoader = (GroovyClassLoader) classLoader;
165+
}
166+
else {
167+
this.groovyClassLoader = buildGroovyClassLoader(classLoader);
168+
}
162169
}
163170

164171
/**

0 commit comments

Comments
 (0)