[groovy] branch GROOVY_3_0_X 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 GROOVY_3_0_X 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 GROOVY_3_0_X
in repository https://gitbox.apache.org/repos/asf/groovy.git


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

commit ce43f10050afd8d990d4f216c3a6b176059eadcf
Author: Paul King <[hidden email]>
AuthorDate: Fri Nov 20 23:02:04 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 +++-
 .../org/codehaus/groovy/tools/shell/commands/ImportCommand.groovy     | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)

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 e85a41e..0aa4731 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)
+            }
         }
     }
 }
diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/commands/ImportCommand.groovy b/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/commands/ImportCommand.groovy
index a9bb41e..6a69f71 100644
--- a/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/commands/ImportCommand.groovy
+++ b/subprojects/groovy-groovysh/src/main/groovy/org/codehaus/groovy/tools/shell/commands/ImportCommand.groovy
@@ -132,7 +132,9 @@ class ImportCommand
         }
         finally {
             // Remove the class generated while testing the import syntax
-            classLoader.removeClassCacheEntry(type?.name)
+            if (type?.name) {
+                classLoader.removeClassCacheEntry(type.name)
+            }
         }
     }
 }