getappmap / appmap-java

AppMap client agent for Java
Other
82 stars 16 forks source link

NPE "Cannot invoke "java.lang.Boolean.booleanValue()" because "event.isStatic" is null" #215

Closed jansorg closed 9 months ago

jansorg commented 1 year ago

I noticed this exception of the Java agent when I executed tests of the AppMap JetBrains plugin. The test failed.

java.lang.NullPointerException: Cannot invoke "java.lang.Boolean.booleanValue()" because "event.isStatic" is null
    at com.appland.appmap.util.StringUtil.canonicalName(StringUtil.java:83)
    at com.appland.appmap.process.hooks.remoterecording.ServletHooks.stopRecording(ServletHooks.java:58)
    at com.appland.appmap.process.hooks.remoterecording.ServletHooks.junit(ServletHooks.java:91)
    at appland.javaAgent.AppMapJavaAgentDownloadServiceTest.multipleDownloadRequests(AppMapJavaAgentDownloadServiceTest.java:62)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:568)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
    at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
    at appland.utils.SystemProperties.withPropertyValue(SystemProperties.java:19)
    at appland.javaAgent.AppMapJavaAgentDownloadServiceTest$1.evaluate(AppMapJavaAgentDownloadServiceTest.java:29)
    at com.intellij.testFramework.UsefulTestCase.lambda$wrapTestRunnable$13(UsefulTestCase.java:554)
    at com.intellij.testFramework.UsefulTestCase.runTestRunnable(UsefulTestCase.java:454)
    at com.intellij.testFramework.fixtures.BasePlatformTestCase.runTestRunnable(BasePlatformTestCase.java:106)
    at com.intellij.testFramework.UsefulTestCase.defaultRunBare(UsefulTestCase.java:470)
    at com.intellij.testFramework.UsefulTestCase.lambda$runBare$12(UsefulTestCase.java:541)
    at com.intellij.testFramework.EdtTestUtil.lambda$runInEdtAndWait$1(EdtTestUtil.java:40)
    at com.intellij.openapi.application.TransactionGuardImpl.runWithWritingAllowed(TransactionGuardImpl.java:214)
    at com.intellij.openapi.application.TransactionGuardImpl.access$200(TransactionGuardImpl.java:21)
    at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:196)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.openapi.application.impl.ApplicationImpl.lambda$invokeAndWait$7(ApplicationImpl.java:450)
    at com.intellij.openapi.application.impl.LaterInvocator$1.run(LaterInvocator.java:134)
    at com.intellij.openapi.application.impl.FlushQueue.doRun(FlushQueue.java:82)
    at com.intellij.openapi.application.impl.FlushQueue.runNextEvent(FlushQueue.java:131)
    at com.intellij.openapi.application.impl.FlushQueue.flushNow(FlushQueue.java:47)
    at com.intellij.openapi.application.impl.FlushQueue$FlushNow.run(FlushQueue.java:187)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:792)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:739)
    at java.desktop/java.awt.EventQueue$3.run(EventQueue.java:733)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:761)
    at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:891)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:760)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:447)
    at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:818)
    at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:446)
    at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:805)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:207)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:92)
brikelly commented 1 year ago

@apotterri Any thoughts on this error?

apotterri commented 1 year ago

@jansorg Can you add some details about how to reproduce this, please?

apotterri commented 1 year ago

I was able to reproduce this by running the tests in appmap-intellij-plugin on Windows. Looks like it's a problem with one of the Junit4 hooks.

kgilpin commented 1 year ago

Are we using JUnit 4, or is IntelliJ using JUnit 4?

jansorg commented 1 year ago

IntelliJ is using JUnit4 and is only very slowly migrating to JUnit 5. AFAIK running with the JUnit5 engine is not possible.

apotterri commented 1 year ago

I'm still going to investigate this, once I get back to working on JUnit support.

I wonder, though, @jansorg... have you actually tried to run the tests using the Vintage engine? I did, and it was able to properly discover and run at least some of them. Do you know of problems I just haven't hit yet?

jansorg commented 1 year ago

I didn't mention the JUnit 5 Vintage engine. By default, JUnit4 is used to run the tests and in my experience it's often a waste of time to attempt to force software into an environment it wasn't engineered for. Until today there was no reason to attempt to run with JUnit 5 Vintage. https://github.com/getappmap/appmap-intellij-plugin/pull/481 is a quick PR to enable the JUnit 5 Vintage engine for our tests. Windows tests are still failing, but apparently with a different error in the agent ("there's no active recording session" and "a recording session already exists")

apotterri commented 1 year ago

Agree about not wasting effort trying to use software in an environment it wasn't engineered for. But, in this case, the Vintage engine was designed for exactly this use case.

Thanks for that PR. We can incorporate it once the JUnit work in the agent is done.

apotterri commented 1 year ago

Turns out I was able to restore support for recording JUnit 4 tests, so now both JUnit 4 and 5 are supported.

@jansorg, it's up to you whether you want to use the Vintage engine going forward. If you do, you can mark #481 as ready-for-review and add me as a reviewer for it. If you don't, you can close it, and this issue as well.

apotterri commented 1 year ago

This is still an issue. This error happens when one of the plugin tests fails, and the agent tries to capture the failure.

appland-release commented 9 months ago

:tada: This issue has been resolved in version 1.26.1 :tada:

The release is available on:

Your semantic-release bot :package::rocket: