groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject incubator-groovy git commit: GROOVY-7424: NPE in SecureASTCustomizer for interface method declarations
Date Thu, 04 Jun 2015 10:08:34 GMT
Repository: incubator-groovy
Updated Branches:
  refs/heads/master b9dafc721 -> b0a30ece1


GROOVY-7424: NPE in SecureASTCustomizer for interface method declarations


Project: http://git-wip-us.apache.org/repos/asf/incubator-groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-groovy/commit/b0a30ece
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/b0a30ece
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/b0a30ece

Branch: refs/heads/master
Commit: b0a30ece1778fef261f28809cfa9e2d1ff925247
Parents: b9dafc7
Author: Paul King <paulk@asert.com.au>
Authored: Thu Jun 4 19:20:52 2015 +1000
Committer: Paul King <paulk@asert.com.au>
Committed: Thu Jun 4 19:20:52 2015 +1000

----------------------------------------------------------------------
 .../groovy/control/customizers/SecureASTCustomizer.java   |  4 ++--
 .../control/customizers/SecureASTCustomizerTest.groovy    | 10 ++++++++++
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/b0a30ece/src/main/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java b/src/main/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
index 6b327da..6911651 100644
--- a/src/main/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
+++ b/src/main/org/codehaus/groovy/control/customizers/SecureASTCustomizer.java
@@ -556,7 +556,7 @@ public class SecureASTCustomizer extends CompilationCustomizer {
             if (clNode!=classNode) {
                 checkMethodDefinitionAllowed(clNode);
                 for (MethodNode methodNode : clNode.getMethods()) {
-                    if (!methodNode.isSynthetic()) {
+                    if (!methodNode.isSynthetic() && methodNode.getCode() != null)
{
                         methodNode.getCode().visit(visitor);
                     }
                 }
@@ -566,7 +566,7 @@ public class SecureASTCustomizer extends CompilationCustomizer {
         List<MethodNode> methods = filterMethods(classNode);
         if (isMethodDefinitionAllowed) {
             for (MethodNode method : methods) {
-                if (method.getDeclaringClass()==classNode) method.getCode().visit(visitor);
+                if (method.getDeclaringClass()==classNode && method.getCode() !=
null) method.getCode().visit(visitor);
             }
         }
     }

http://git-wip-us.apache.org/repos/asf/incubator-groovy/blob/b0a30ece/src/test/org/codehaus/groovy/control/customizers/SecureASTCustomizerTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/control/customizers/SecureASTCustomizerTest.groovy
b/src/test/org/codehaus/groovy/control/customizers/SecureASTCustomizerTest.groovy
index 07f25a4..56832ce 100644
--- a/src/test/org/codehaus/groovy/control/customizers/SecureASTCustomizerTest.groovy
+++ b/src/test/org/codehaus/groovy/control/customizers/SecureASTCustomizerTest.groovy
@@ -410,6 +410,16 @@ class SecureASTCustomizerTest extends GroovyTestCase {
         assert hasSecurityException {shell.evaluate('def x() { System.println(1) }')}
     }
 
+    // GROOVY-7424
+    void testClassWithInterfaceVisitable() {
+        def shell = new GroovyShell(configuration)
+        shell.evaluate '''
+            interface Foo { def baz() }
+            class Bar implements Foo { def baz() { 42 }}
+            assert new Bar().baz() == 42
+        '''
+    }
+
     // GROOVY-6153
     void testDeterministicWhitelistBehaviour() {
         def shell = new GroovyShell(configuration)


Mime
View raw message