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


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

commit e48ca4796f4356caa10d67d87b15ed3b342f0189
Author: Paul King <[hidden email]>
AuthorDate: Fri Nov 20 23:00:44 2020 +1000

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

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 894d076..d545f65 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
@@ -131,7 +131,9 @@ class ImportCommand
         }
         finally {
             // Remove the class generated while testing the import syntax
-            classLoader.removeClassCacheEntry(type?.name)
+            if (type?.name) {
+                classLoader.removeClassCacheEntry(type.name)
+            }
         }
     }
 }