groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sun...@apache.org
Subject [groovy] 03/06: Trivial refactoring: simplify code with lambda
Date Sat, 11 Jan 2020 17:59:03 GMT
This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 8e200a3031a3654b4c5c0aef06fc91ab64340ed6
Author: Daniel Sun <sunlan@apache.org>
AuthorDate: Sun Jan 12 01:20:49 2020 +0800

    Trivial refactoring: simplify code with lambda
    
    (cherry picked from commit 6d4aad7c9fc3542b9d3b011b4738599cc33a3d9f)
---
 .../src/main/groovy/groovy/text/GStringTemplateEngine.java     | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
b/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
index 27c53de..9f2dfd8 100644
--- a/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
+++ b/subprojects/groovy-templates/src/main/groovy/groovy/text/GStringTemplateEngine.java
@@ -189,12 +189,10 @@ public class GStringTemplateEngine extends TemplateEngine {
             templateExpressions.append("}}");
 
             // Use a new class loader by default for each class so each class can be independently
garbage collected
-            final GroovyClassLoader loader = reuseClassLoader && parentLoader instanceof
GroovyClassLoader?(GroovyClassLoader)parentLoader:(
-                    (GroovyClassLoader) AccessController.doPrivileged(new PrivilegedAction()
{
-                        public Object run() {
-                            return new GroovyClassLoader(parentLoader);
-                        }
-                    }));
+            final GroovyClassLoader loader =
+                    reuseClassLoader && parentLoader instanceof GroovyClassLoader
+                            ? (GroovyClassLoader) parentLoader
+                            : AccessController.doPrivileged((PrivilegedAction<GroovyClassLoader>)
() -> new GroovyClassLoader(parentLoader));
             final Class groovyClass;
             try {
                 groovyClass = loader.parseClass(new GroovyCodeSource(templateExpressions.toString(),
"GStringTemplateScript" + counter.incrementAndGet() + ".groovy", "x"));


Mime
View raw message