NPE in AnnotationUtil.findAnnotation

Morning all,

I've recently been getting reports of an NPE triggering inside the TestNG plugin which is being tripped up inside the AnnotationUtil.findAnnotation() method from IDEAs code insight.

I'm not sure what annotations are being used by the users, or what annotation might be triggering the problem (have asked for sample projects to reproduce it, but nothing yet).

I was just wonder if anyone else had seen this problem and have an idea about whats triggering it?

Mark


Error during dispatching of
java.awt.event.MouseEvent[MOUSE_RELEASED,(103,489),button=1,modifiers=Button1,clickCount=1]
on ###overrideRedirect###
java.lang.NullPointerException
at
com.intellij.codeInsight.AnnotationUtil.findAnnotation(AnnotationUtil.java:73)
at
com.theoryinpractice.testng.util.TestNGUtil.filterAnnotations(TestNGUtil.java:148)
at
com.theoryinpractice.testng.TestNGRunnableState.calculateDependencies(TestNGRunnableState.java:422)
at
com.theoryinpractice.testng.TestNGRunnableState.createJavaParameters(TestNGRunnableState.java:243)
at
com.intellij.execution.configurations.JavaCommandLineState.getJavaParameters(JavaCommandLineState.java:30)
at
com.intellij.execution.runners.RunStrategy.executeCommandLine(RunStrategy.java:41)
at com.intellij.execution.runners.RunStrategy.a(RunStrategy.java:67)
at
com.intellij.execution.runners.RunStrategy.access$000(RunStrategy.java:46)
at com.intellij.execution.runners.RunStrategy$3.run(RunStrategy.java:6)
at
com.intellij.execution.impl.ExecutionManagerImpl$1.run(ExecutionManagerImpl.java:9)
at
com.intellij.execution.impl.ExecutionManagerImpl.compileAndRun(ExecutionManagerImpl.java:25)
at
com.intellij.execution.runners.RunStrategy.execute(RunStrategy.java:35)
at
com.intellij.execution.runners.RunStrategy.execute(RunStrategy.java:90)
at
com.intellij.execution.actions.RunContextAction.perform(RunContextAction.java:1)
at
com.intellij.execution.actions.BaseRunConfigurationAction.actionPerformed(BaseRunConfigurationAction.java:14)
at
com.intellij.openapi.actionSystem.impl.ActionMenuItem$ActionTransmitter.actionPerformed(ActionMenuItem.java:8)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1882)
at
com.intellij.openapi.actionSystem.impl.ActionMenuItem.fireActionPerformed(ActionMenuItem.java:24)
at com.intellij.ui.plaf.beg.BegMenuItemUI.a(BegMenuItemUI.java:110)
at
com.intellij.ui.plaf.beg.BegMenuItemUI.access$300(BegMenuItemUI.java:84)
at
com.intellij.ui.plaf.beg.BegMenuItemUI$MyMouseInputHandler.mouseReleased(BegMenuItemUI.java:7)
at java.awt.Component.processMouseEvent(Component.java:5554)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
at java.awt.Component.processEvent(Component.java:5319)
at java.awt.Container.processEvent(Container.java:2010)
at java.awt.Component.dispatchEventImpl(Component.java:4021)
at java.awt.Container.dispatchEventImpl(Container.java:2068)
at java.awt.Component.dispatchEvent(Component.java:3869)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4256)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:3936)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3866)
at java.awt.Container.dispatchEventImpl(Container.java:2054)
at java.awt.Window.dispatchEventImpl(Window.java:1774)
at java.awt.Component.dispatchEvent(Component.java:3869)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at com.intellij.ide.IdeEventQueue.b(IdeEventQueue.java:15)
at com.intellij.ide.IdeEventQueue.a(IdeEventQueue.java:71)
at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:84)
at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:269)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:184)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:176)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

2 comments
Comment actions Permalink

Good night here,
it seems that TestNG does not check for null PsiModifierListOwner when calling findAnnotation. @NotNull for this parameter should be added.

Eugene.

0
Comment actions Permalink

Eugene Vigdorchik wrote on 13/01/07 00:57:

it seems that TestNG does not check for null PsiModifierListOwner
when calling findAnnotation. @NotNull for this parameter should be
added.



Hi Eugene,

Even after added null checks before calling findAnnotations I seem to
get a few NPEs reported by users - some report the problem has gone away
so I'm guessing some Psi element thats getting passed in ALSO has a null
inside it which is triggering the NPE.

I see Hani had added a comment to part of the code that a
PsiAnonymousElement (i think thats the right class) was triggering an
NPE so was being skipped preemptively. I wonder if theres other Psi
classes also with the same behaviour.

0

Please sign in to leave a comment.