AFTER WRITE - NullPointerException
radek.koubsky Oct 4, 2015 6:20 PMHello,
I reported one issue (the first one in Unexpected behavior in TRY-CATCH-FINALLY) with AFTER WRITE location specifier which throws NullPointerException after compilation.
I have same problem, but I am not sure if this is the same situation because there is no try-catch-finally around the definition of local variable interceptorBindings, which is used for AFTER WRITE.
Env:
Byteman 3.0.1
wildfly-8.2.0.Final - wildfly/Jsr299BindingsInterceptor.java at 8.x · wildfly/wildfly · GitHub
Source code:
@Override public Object processInvocation(final InterceptorContext context) throws Exception { final ComponentInstance componentInstance = context.getPrivateData(ComponentInstance.class); final WeldInterceptorInstances interceptorInstances = (WeldInterceptorInstances) componentInstance.getInstanceData(SerializedCdiInterceptorsKey.class); final InterceptorBindings interceptorBindings = this.interceptorBindings.getValue(); switch (interceptionType) { case AROUND_INVOKE: return doMethodInterception(context.getInvocationContext(), InterceptionType.AROUND_INVOKE, interceptorInstances, interceptorBindings); case AROUND_TIMEOUT: return doMethodInterception(context.getInvocationContext(), InterceptionType.AROUND_TIMEOUT, interceptorInstances, interceptorBindings); case PRE_DESTROY: try { return doLifecycleInterception(context, interceptorInstances, interceptorBindings); } finally { interceptorInstances.getCreationalContext().release(); } case POST_CONSTRUCT: return doLifecycleInterception(context, interceptorInstances, interceptorBindings); case AROUND_CONSTRUCT: return doLifecycleInterception(context, interceptorInstances, interceptorBindings); default: //should never happen return context.proceed(); }
and my rule:
#Log process invocation RULE logJsr299BindingsInterceptor.processInvocation CLASS org.jboss.as.weld.ejb.Jsr299BindingsInterceptor METHOD processInvocation(InterceptorContext) AFTER WRITE $interceptorBindings IF true DO log($CLASS, "DEBUG", "(Method processInvocation) Processing invocation, getting interceptor instances and bindings:\n" + "InterceptorContext: " + $context + "\ninterceptionType: " + $0.interceptionType + "\ninterceptorInstances: " + ($interceptorInstances == null ? "null" : $interceptorInstances.interceptorInstances) + "\n" + "interceptorBindings - all interceptors: " + ($interceptorBindings == null ? "null" : $interceptorBindings.getAllInterceptors()))
this throws NullPointerException when rule is being compiled:
RULE logJsr299BindingsInterceptor.processInvocation
CLASS org.jboss.as.weld.ejb.Jsr299BindingsInterceptor
METHOD processInvocation(InterceptorContext)
HELPER org.jboss.byteman.koubsky.LogHelper
AFTER WRITE $interceptorBindings
IF true
DO log($CLASS, "DEBUG", "(Method processInvocation) Processing invocation, getting interceptor instances and bindings:\n" +
"InterceptorContext: " + $context + "\ninterceptionType: " + $0.interceptionType +
"\ninterceptorInstances: " + ($interceptorInstances == null ? "null" : $interceptorInstances.interceptorInstances) +
"\n" + "interceptorBindings - all interceptors: " + ($interceptorBindings == null ? "null" : $interceptorBindings.getAllInterceptors()))
ENDRULE
Transformed in:
loader: ModuleClassLoader for Module "org.jboss.as.weld:main" from local module loader @6fb525d8 (finder: local module finder @5dc7c133 (roots: /home/koubsky/Wildfly8/wildfly-8.2.0.Final/modules,/home/koubsky/Wildfly8/wildfly-8.2.0.Final/modules/system/layers/base))
trigger class: org.jboss.as.weld.ejb.Jsr299BindingsInterceptor
threw java.lang.NullPointerException
java.lang.NullPointerException
at org.jboss.byteman.agent.adapter.cfg.CFG.inBytemanTrigger(CFG.java:1704)
at org.jboss.byteman.agent.adapter.RuleTriggerMethodAdapter.inBytemanTrigger(RuleTriggerMethodAdapter.java:588)
at org.jboss.byteman.agent.adapter.VariableAccessTriggerAdapter$VariableAccessTriggerMethodAdapter.visitVarInsn(VariableAccessTriggerAdapter.java:136)
at org.jboss.byteman.objectweb.asm.tree.VarInsnNode.accept(Unknown Source)
at org.jboss.byteman.agent.adapter.BMInsnList.accept(BMInsnList.java:81)
at org.jboss.byteman.objectweb.asm.tree.MethodNode.accept(Unknown Source)
at org.jboss.byteman.objectweb.asm.commons.JSRInlinerAdapter.visitEnd(Unknown Source)
at org.jboss.byteman.objectweb.asm.ClassReader.b(Unknown Source)
at org.jboss.byteman.objectweb.asm.ClassReader.accept(Unknown Source)
at org.jboss.byteman.objectweb.asm.ClassReader.accept(Unknown Source)
at org.jboss.byteman.agent.TransformContext.transform(TransformContext.java:150)
at org.jboss.byteman.agent.Transformer.transform(Transformer.java:746)
at org.jboss.byteman.agent.Transformer.tryTransform(Transformer.java:814)
at org.jboss.byteman.agent.Transformer.tryTransform(Transformer.java:785)
at org.jboss.byteman.agent.Transformer.transform(Transformer.java:257)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:424)
at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:144)
at org.jboss.byteman.agent.Retransformer.installScript(Retransformer.java:144)
at org.jboss.byteman.agent.TransformListener.handleScripts(TransformListener.java:349)
at org.jboss.byteman.agent.TransformListener.loadScripts(TransformListener.java:272)
at org.jboss.byteman.agent.TransformListener.handleConnection(TransformListener.java:225)
at org.jboss.byteman.agent.TransformListener.run(TransformListener.java:158)
Thanks for your comments.