Uninformative NullPointerException by build scan plugin

I converted a working groovy build script of a very big multi-project to kotlin. It seems to work, but the scan publishing fails:

BUILD SUCCESSFUL in 2m 51s
249 actionable tasks: 233 executed, 16 up-to-date

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

----------
Gradle version: 5.4.1
Plugin version: 2.1

java.lang.NullPointerException
        at com.gradle.scan.plugin.internal.j.d$a.a(SourceFile:51)
        at com.gradle.scan.plugin.internal.j.d.a(SourceFile:41)
        at com.gradle.scan.plugin.internal.j.f.a(SourceFile:42)
        at com.gradle.scan.plugin.internal.o.a$a.a(SourceFile:30)
        at com.gradle.scan.plugin.internal.o.a$a.a(SourceFile:19)
        at com.gradle.scan.plugin.internal.o.a.c(SourceFile:60)

----------

Is there anything obvious I’m overlooking? The stacktrace is unhelpful to me for debugging the issue.

saw your email. let’s continue here

Hello Danilo,

thanks for the report.

Does build scan start failing for you after you updated the build scans plugin version or gradle itself or is this the first time you use build scans with this build?

cheers,

René

Hi,
the plugin was enabled and working before the switch to kts. I made some improvements to the build (e.g. I’m using the buildSrc plugin now), and I can’t reproduce the issue any longer. I’m not sure it’s good, does the stacktrace point to any obvious possible NPE source?

Hi @Rene,
I got an update. The problem still stands and it is not reproducible: re-launching a build usually fixes it. It seems to appear randomly, independently of the platform and JDK. Can it be a concurrency problem? I cannot justify it otherwise.

This was on Travis CI, Linux Xenial, OpenJDK12

> Task :alchemist-engine:dokka FAILED
294 actionable tasks: 277 executed, 17 up-to-date
A build scan cannot be produced as an error occurred gathering build data.
Please report this problem via https://gradle.com/scans/help/plugin and include the following via copy/paste:
----------
Gradle version: 5.4.1
Plugin version: 2.3
java.lang.NullPointerException
	at com.gradle.scan.plugin.internal.j.d$a.a(SourceFile:51)
	at com.gradle.scan.plugin.internal.j.d.a(SourceFile:41)
	at com.gradle.scan.plugin.internal.j.f.a(SourceFile:42)
	at com.gradle.scan.plugin.internal.o.a$a.a(SourceFile:30)
	at com.gradle.scan.plugin.internal.o.a$a.a(SourceFile:19)
	at com.gradle.scan.plugin.internal.o.a.c(SourceFile:60)
----------

Travis OSX, OpenJDK12

> Task :alchemist-loading:dokka
Unresolved link to 0,1 in doc comment of it.unibo.alchemist.loader.displacements.AbstractRandomDisplacement$randomDouble() (AbstractRandomDisplacement.kt:54)
> Task :alchemist-maps:dokka FAILED
304 actionable tasks: 287 executed, 17 up-to-date
A build scan cannot be produced as an error occurred gathering build data.
Please report this problem via https://gradle.com/scans/help/plugin and include the following via copy/paste:
----------
Gradle version: 5.4.1
Plugin version: 2.3
java.lang.NullPointerException
	at com.gradle.scan.plugin.internal.j.d$a.a(SourceFile:51)
	at com.gradle.scan.plugin.internal.j.d.a(SourceFile:41)
	at com.gradle.scan.plugin.internal.j.f.a(SourceFile:42)
	at com.gradle.scan.plugin.internal.o.a$a.a(SourceFile:30)
	at com.gradle.scan.plugin.internal.o.a$a.a(SourceFile:19)
	at com.gradle.scan.plugin.internal.o.a.c(SourceFile:60)
----------

Linux, OpenJDK8

> Task :alchemist-incarnation-biochemistry:dokka FAILED
297 actionable tasks: 280 executed, 17 up-to-date
A build scan cannot be produced as an error occurred gathering build data.
Please report this problem via https://gradle.com/scans/help/plugin and include the following via copy/paste:
----------
Gradle version: 5.4.1
Plugin version: 2.3
java.lang.NullPointerException
	at com.gradle.scan.plugin.internal.j.d$a.a(SourceFile:51)
	at com.gradle.scan.plugin.internal.j.d.a(SourceFile:41)
	at com.gradle.scan.plugin.internal.j.f.a(SourceFile:42)
	at com.gradle.scan.plugin.internal.o.a$a.a(SourceFile:30)
	at com.gradle.scan.plugin.internal.o.a$a.a(SourceFile:19)
	at com.gradle.scan.plugin.internal.o.a.c(SourceFile:60)
----------

Hi @DanySK,

This is indeed a concurrency problem within Gradle. We are working on a fix. In the meantime, unfortunately there is nothing you can do to prevent it from happening.

1 Like

This here is a genuinely „witchy“ coincidence! I just solved a pesky Heisenbug myself in my own code not 15 minutes before you posted this.

After a hair-tearing-out debugging session, I feel compelled to show my gratitude to The Universe for finally revealing a solution to me: Make sure nothing in your scan plugin code there is storing anything in a private static final ConcurrentHashMap like mine was.

Not that Gradle Core Devs would ever make the kind of oversights that I made. But I’m so stoked that I fixed mine that I just want to share the awesome sense of relief I’m feeling right now with anybody who might have an even remotely similar bug :slight_smile:

Can you share the issue number that this will be tracked under @luke_daley? Watching the progress of this one could be a golden learning opportunity.

Thanks @luke_daley, please keep us posted!