Build scan java.lang.NullPointerException


(Yi Cheng) #1

Hi,

I am using the build scan plugin, in most cases it works well, e.g.
./gradlew :app:xxx:tasks
./gradlew :app:xxx:checkstyle

but when it comes to test, it fails with the following error. I tried with -S options to gradle, but it does not seem to help on printing the full stacktrace. would appreciate some pointers here.

:app:xxx:testDefaultDebugUnitTest: 7552 tests completed, 7544 passed, 8 skipped

BUILD SUCCESSFUL

Total time: 7 mins 51.108 secs

A build scan cannot be produced as an error occurred gathering build data.
Please report this problem via https://ge.xxx.biz/help and include the following via copy/paste:

----------
Gradle version: 3.5
Plugin version: 1.7.3

java.lang.NullPointerException
        at com.gradle.scan.plugin.internal.a.m.e.a(SourceFile:71)
        at com.gradle.scan.plugin.internal.c.e.run(SourceFile:62)


java.lang.NullPointerException
        at com.gradle.scan.plugin.internal.a.m.e.a(SourceFile:71)
        at com.gradle.scan.plugin.internal.c.e.run(SourceFile:62)

...(repeat x1000 times)

it only repros with a clean first, otherwise it runs just fine.

./gradlew clean
./gradlew :app:xxx:testDefaultDebugUnitTest --scan

Thanks,
Yi


(Tim Yates) #2

Hi Yi

Would it be possible for you to try with version 1.7.4 of the plugin?

Wondering if that has the same issue

Thanks!

Tim


(Yi Cheng) #3

Hi Tim,

I did a clean build and test with 1.7.4, similar error, but interestingly it gives a better stacktrace:

Unknown test task operation id: 71654
java.lang.IllegalStateException: Unknown test task operation id: 71654
        at com.gradle.scan.plugin.internal.a.m.c.a(SourceFile:1014)
        at com.gradle.scan.plugin.internal.a.m.k.started(SourceFile:33)
        at sun.reflect.GeneratedMethodAccessor567.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:305)
        at org.gradle.internal.event.DefaultListenerManager$ListenerDetails.dispatch(DefaultListenerManager.java:285)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
        at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:273)
        at org.gradle.internal.event.DefaultListenerManager$EventBroadcast$ListenerDispatch.dispatch(DefaultListenerManager.java:260)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:42)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:221)
        at org.gradle.internal.event.BroadcastDispatch$SingletonDispatch.dispatch(BroadcastDispatch.java:145)
        at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:58)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:315)
        at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:225)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:138)
        at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:35)
        at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
        at com.sun.proxy.$Proxy137.started(Unknown Source)
        at org.gradle.api.internal.tasks.testing.results.StateTrackingTestResultProcessor.started(StateTrackingTestResultProcessor.java:47)
        at org.gradle.api.internal.tasks.testing.results.AttachParentTestResultProcessor.started(AttachParentTestResultProcessor.java:38)
        at sun.reflect.GeneratedMethodAccessor574.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
        at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
        at org.gradle.internal.dispatch.FailureHandlingDispatch.dispatch(FailureHandlingDispatch.java:29)
        at org.gradle.internal.dispatch.AsyncDispatch.dispatchMessages(AsyncDispatch.java:132)
        at org.gradle.internal.dispatch.AsyncDispatch.access$000(AsyncDispatch.java:33)
        at org.gradle.internal.dispatch.AsyncDispatch$1.run(AsyncDispatch.java:72)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:748)

These stacktraces (about 8000 instances ~= # of the tests) keep popping out while the tests are running. Initially I thought this could be related to build scan plugin not getting initialized early enough, so I added it to ~/.gradle/init.gradle, but still got the same result.

Edit:
same error -> similar error
also this time the tests will exit 1 because of the exception, unlike 1.7.3’s exit code being 0, and

java.lang.NullPointerException
        at com.gradle.scan.plugin.internal.a.m.n.a(SourceFile:67)
        at com.gradle.scan.plugin.internal.c.e.run(SourceFile:62)

still shows up at the end.


(Tim Yates) #4

Very odd…

Is this an android build? Which kind of tests are they? Are they running on the device, or are they regular unit tests?

Wondering if it’s some unexpected interaction from the Android plugin that’s causing us some issues…

Cheers,

Tim


(Yi Cheng) #5

Yes, android build. They are regular units tests with roboletrics running on linux/mac. Let me know how we can further debug this, or setup a debug session if needed. cc @mark_vieira


(Tim Yates) #6

Can you run:

./gradlew :app:xxx:model

And paste the output here?


(Yi Cheng) #7

To close this one out. The cause is that internally we have a custom test runner, which created task id that buildscan does not know about.

In our plugin, instead of final Object testTaskOperationId = mBuildOperationExecutor.getCurrentOperation().getId(); ,
final Object testTaskOperationId = mBuildOperationExecutor.getCurrentOperation().getParentId(); did the trick.