[
https://issues.apache.org/jira/browse/BEAM-12215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17549262#comment-17549262
]
Danny McCormick commented on BEAM-12215:
----------------------------------------
This issue has been migrated to https://github.com/apache/beam/issues/20869
> DirectRunner NullPointerException
> ---------------------------------
>
> Key: BEAM-12215
> URL: https://issues.apache.org/jira/browse/BEAM-12215
> Project: Beam
> Issue Type: Bug
> Components: runner-direct, sdk-java-core, testing
> Affects Versions: 2.28.0
> Reporter: Lai Jiang
> Priority: P3
>
> When using the {{DirectRunner}} in tests I encountered flaky tests due to
> {{NullPointerException}}.
> When the test fails the relevant stack trace is like below:
>
>
> {code:java}
> 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){code}
>
>
> However the null pointer seems to have come from calling (a repackaged and
> very innocent looking) guava function to set the {{ThreadFactory}}:
>
> {code:java}
> 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());{code}
>
> Which in turn is just calling
> java.util.concurrent.Executors.defaulThreatFactory() when not on App Engine:
>
> {code:java}
> @Beta
> @GwtIncompatible
> public static ThreadFactory platformThreadFactory() {
> if (!isAppEngine()) {
> return Executors.defaultThreadFactory();
> } else {
> ...
> } {code}
>
> 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!
--
This message was sent by Atlassian Jira
(v8.20.7#820007)