RFR: 7903336: java.lang.NullPointerException: at com.sun.javatest.TestSuite$GeneralPurposeLogger.<init>(TestSuite.java:1494)

Leonid Kuskov lkuskov at openjdk.org
Fri Sep 30 02:19:33 UTC 2022


On Fri, 30 Sep 2022 00:01:15 GMT, Dmitry Bessonov <dbessono at openjdk.org> wrote:

> 7903336: java.lang.NullPointerException: at com.sun.javatest.TestSuite$GeneralPurposeLogger.<init>(TestSuite.java:1494)
> 
> Noticed when running a test suite:
> 
> java.lang.NullPointerException
> at java.base/java.util.Objects.requireNonNull(Objects.java:233)
> at java.logging/java.util.logging.Logger.addHandler(Logger.java:2064)
> at com.sun.javatest.TestSuite$GeneralPurposeLogger.<init>(TestSuite.java:1494)
> at com.sun.javatest.TestSuite$GeneralPurposeLogger.<init>(TestSuite.java:1481)
> at com.sun.javatest.TestSuite.createLog(TestSuite.java:1303)
> at com.sun.javatest.services.Service.createLog(Service.java:325)
> at com.sun.javatest.services.ServiceManager.setParameters(ServiceManager.java:133)
> at com.sun.javatest.services.ServiceManager.setHarness(ServiceManager.java:126)
> at com.sun.javatest.TestSuite.starting(TestSuite.java:546)
> at com.sun.jck.lib.JCKTestSuite.starting(JCKTestSuite.java:268)
> at com.sun.javatest.Harness.runTests(Harness.java:751)
> at com.sun.javatest.Harness.batch(Harness.java:447)
> at com.sun.javatest.batch.RunTestsCommand.run(RunTestsCommand.java:116)
> at com.sun.javatest.tool.CommandContext.runCommands(CommandContext.java:198)
> at com.sun.javatest.tool.Main.run(Main.java:427)
> at com.sun.javatest.tool.Main.main0(Main.java:139)
> at com.sun.javatest.tool.Main.main(Main.java:117)

>From my point of view the corner case isn't "non thread safe" HashMap but it is potential null of `new WorkDirLogHandler(ts.getObservedFile(wd)` . This code can use only 2 HashMap commands:
1. ` if (!handlersMap.containsKey(logFileName) {` and  
2. ` handlersMap.put(logFileName, wdlh);` if wdlh isn't `null` 
3. and the last command of the block is `addHandler(wdlh);`

-------------

PR: https://git.openjdk.org/jtharness/pull/40


More information about the jtharness-dev mailing list