You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by su...@apache.org on 2019/11/03 15:42:25 UTC

[groovy] 09/18: Fix "java.lang.RuntimeException: No suitable ClassLoader found for grab" caused by refactoring

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 7a70cbde51c399819f07be9491d14737711e0e9e
Author: Daniel Sun <su...@apache.org>
AuthorDate: Sun Nov 3 22:22:23 2019 +0800

    Fix "java.lang.RuntimeException: No suitable ClassLoader found for grab" caused by refactoring
    
    (cherry picked from commit df2807701995a592763065d0e84fdfd507bd5c77)
---
 src/main/java/groovy/grape/Grape.java | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/src/main/java/groovy/grape/Grape.java b/src/main/java/groovy/grape/Grape.java
index dfe7a37..7ab4328 100644
--- a/src/main/java/groovy/grape/Grape.java
+++ b/src/main/java/groovy/grape/Grape.java
@@ -157,21 +157,24 @@ public class Grape {
 
     public static void grab(final Map<String, Object> args, final Map... dependencies) {
         if (enableGrapes) {
-            AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
-                GrapeEngine instance = getInstance();
-                if (instance != null) {
-                    if (!args.containsKey(AUTO_DOWNLOAD_SETTING)) {
-                        args.put(AUTO_DOWNLOAD_SETTING, enableAutoDownload);
+            AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                @Override
+                public Void run() {
+                    GrapeEngine instance = getInstance();
+                    if (instance != null) {
+                        if (!args.containsKey(AUTO_DOWNLOAD_SETTING)) {
+                            args.put(AUTO_DOWNLOAD_SETTING, enableAutoDownload);
+                        }
+                        if (!args.containsKey(DISABLE_CHECKSUMS_SETTING)) {
+                            args.put(DISABLE_CHECKSUMS_SETTING, disableChecksums);
+                        }
+                        if (!args.containsKey(GrapeEngine.CALLEE_DEPTH)) {
+                            args.put(GrapeEngine.CALLEE_DEPTH, GrapeEngine.DEFAULT_CALLEE_DEPTH + 2);
+                        }
+                        instance.grab(args, dependencies);
                     }
-                    if (!args.containsKey(DISABLE_CHECKSUMS_SETTING)) {
-                        args.put(DISABLE_CHECKSUMS_SETTING, disableChecksums);
-                    }
-                    if (!args.containsKey(GrapeEngine.CALLEE_DEPTH)) {
-                        args.put(GrapeEngine.CALLEE_DEPTH, GrapeEngine.DEFAULT_CALLEE_DEPTH + 2);
-                    }
-                    instance.grab(args, dependencies);
+                    return null;
                 }
-                return null;
             });
         }
     }