[groovy] branch master updated: GROOVY-9758: groovsh import of non existing class throws null pointer instead of syntax error (avoid NPE)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[groovy] branch master updated: GROOVY-9758: groovsh import of non existing class throws null pointer instead of syntax error (avoid NPE)

paulk
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/master by this push:
     new 76954b0  GROOVY-9758: groovsh import of non existing class throws null pointer instead of syntax error (avoid NPE)
76954b0 is described below

commit 76954b063eb5a106e1b8d7e7451950965dd4511a
Author: Paul King <[hidden email]>
AuthorDate: Fri Nov 20 23:02:47 2020 +1000

    GROOVY-9758: groovsh import of non existing class throws null pointer instead of syntax error (avoid NPE)
---
 .../groovy/org/apache/groovy/groovysh/commands/ImportCommand.groovy   | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ImportCommand.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ImportCommand.groovy
index 9dc5585..75add64 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ImportCommand.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/commands/ImportCommand.groovy
@@ -129,7 +129,9 @@ class ImportCommand extends CommandSupport {
         }
         finally {
             // Remove the class generated while testing the import syntax
-            classLoader.removeClassCacheEntry(type?.name)
+            if (type?.name) {
+                classLoader.removeClassCacheEntry(type.name)
+            }
         }
     }
 }