You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by pa...@apache.org on 2015/06/04 11:48:58 UTC
incubator-groovy git commit: GROOVY-7424: NPE in SecureASTCustomizer
for interface method declarations
Repository: incubator-groovy
Updated Branches:
refs/heads/GROOVY_2_4_X 8429018ad -> 02d8a210c
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/02d8a210
Tree: http://git-wip-us.apache.org/repos/asf/incubator-groovy/tree/02d8a210
Diff: http://git-wip-us.apache.org/repos/asf/incubator-groovy/diff/02d8a210
Branch: refs/heads/GROOVY_2_4_X
Commit: 02d8a210c9ee996c72fe046b8d1cf18828e4cfd0
Parents: 8429018
Author: Paul King <pa...@asert.com.au>
Authored: Thu Jun 4 19:20:52 2015 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Thu Jun 4 19:48:44 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/02d8a210/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 0a35979..c0b8aad 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/02d8a210/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)