damccorm opened a new issue, #20869:
URL: https://github.com/apache/beam/issues/20869
When using the `DirectRunner` in tests I encountered flaky tests due to
`NullPointerException`.
When the test fails the relevant stack trace is like below:
```
java.lang.NullPointerException
at
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.base.Preconditions.checkNotNull(Preconditions.java:877)
at
org.apache.beam.vendor.guava.v26_0_jre.com.google.common.util.concurrent.ThreadFactoryBuilder.setThreadFactory(ThreadFactoryBuilder.java:132)
at org.apache.beam.runners.direct.DirectRunner.run(DirectRunner.java:192)
at org.apache.beam.runners.direct.DirectRunner.run(DirectRunner.java:67)
at org.apache.beam.sdk.Pipeline.run(Pipeline.java:322)
at
google.registry.beam.TestPipelineExtension.run(TestPipelineExtension.java:344)
at
google.registry.beam.TestPipelineExtension.run(TestPipelineExtension.java:324)
at
google.registry.beam.spec11.Spec11PipelineTest.testSuccess_saveToGcs(Spec11PipelineTest.java:185)
```
However the null pointer seems to have come from calling (a repackaged and
very innocent looking) guava function to set the `ThreadFactory`:
```
ExecutorService metricsPool =
Executors.newCachedThreadPool(
new ThreadFactoryBuilder()
.setThreadFactory(MoreExecutors.platformThreadFactory())
.setDaemon(false) // otherwise you say you want to leak, please don't!
.setNameFormat("direct-metrics-counter-committer")
.build());
```
Which in turn is just calling
java.util.concurrent.Executors.defaulThreatFactory() when not on App Engine:
```
@Beta
@GwtIncompatible
public static ThreadFactory platformThreadFactory() {
if (!isAppEngine())
{
return Executors.defaultThreadFactory();
} else {
...
}
```
I don't understand how this could possibly have failed. The test seems to be
only flaky on our CI servers running Ubuntu and I haven't been able to
reproduce it locally, making debugging a challenge.
I'd appreciate any input you may have. Thanks!
Imported from Jira
[BEAM-12215](https://issues.apache.org/jira/browse/BEAM-12215). Original Jira
may contain additional context.
Reported by: jianglai.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]