Bug 541493 - NPE after assertNotNull in FileSystemResourceManagerTest
Summary: NPE after assertNotNull in FileSystemResourceManagerTest
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 4.10   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 4.10 RC1   Edit
Assignee: Simeon Andreev CLA
QA Contact:
URL:
Whiteboard:
Keywords: test
Depends on:
Blocks:
 
Reported: 2018-11-23 06:02 EST by Andrey Loskutov CLA
Modified: 2021-02-12 02:24 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2018-11-23 06:02:14 EST
In the Gerrit builds we observe an NPE which can't be:

java.lang.NullPointerException
	at org.eclipse.core.tests.internal.localstore.FileSystemResourceManagerTest.write(FileSystemResourceManagerTest.java:483)
	at org.eclipse.core.tests.internal.localstore.FileSystemResourceManagerTest.testWriteFile(FileSystemResourceManagerTest.java:380)

https://ci.eclipse.org/platform/job/eclipse.platform.resources-Gerrit/1024/testReport/junit/org.eclipse.core.tests.internal.localstore/FileSystemResourceManagerTest/testWriteFile/

The code in FileSystemResourceManagerTest:

IWorkspace workspace = getWorkspace();
assertNotNull("workspace cannot be null", workspace);
workspace.run(new WriteFileContents(), null);  // NPE here !!!

HOW it can be an NPE???
Comment 1 Andrey Loskutov CLA 2018-11-23 09:36:41 EST
Simeon, Stephan: I have really no idea how we can get a NPE here. It can't be, but we see it in Gerrit. Any ideas? Is this something in compiler broken? But why it fails only sporadically? This one is really puzzling.
Comment 2 Simeon Andreev CLA 2018-11-23 09:46:21 EST
The stack trace can't be reliable. Even before this, it reported that getWorkspace() returned a null. Only the method throws an illegal state exception instead of returning a null...

Unfortunately the rest of the stack traces I've been seeing from bad core resources tests have been all reliable (imagine that). So maybe something in the file is not handled well? I did change the lambda in the method which throws the exception. But this is only *one* lambda... Maybe I should just change all of them , so that we at least know *where* FileSystemResourceManagerTest.testWriteFile() fails?
Comment 3 Simeon Andreev CLA 2018-11-23 09:50:32 EST
Do note that before changing the lambda to a class, the NPE was supposed to be somewhere in the lambda expression (again at a very unlikely location):

assertNotNull("file system resource manager cannot be null", localManager);
localManager.write(file, contents, info, flags, false, null);

And I'm rather certain I added the assertNotNull statements because the stack traces were not useful even before any changes.
Comment 4 Andrey Loskutov CLA 2018-11-23 10:24:57 EST
As discussed on the phone, we think this can only be some weird JUnit framework bug, which doesn't print the *original* exception stack, so we want wrap the entire block into try/catch and print the original NPE to see what is going wrong and where. Simeon will provide a gerrit.
Comment 5 Eclipse Genie CLA 2018-11-23 10:31:05 EST
New Gerrit change created: https://git.eclipse.org/r/132987
Comment 7 Stephan Herrmann CLA 2018-11-23 13:39:30 EST
(In reply to Andrey Loskutov from comment #1)
> Simeon, Stephan: I have really no idea how we can get a NPE here. It can't
> be, but we see it in Gerrit. Any ideas? Is this something in compiler
> broken? But why it fails only sporadically? This one is really puzzling.

Did it fail more than once?

Would have been interesting to pick up the class file from a failing build.

Too late to cry?
Comment 8 Jörg Kubitz CLA 2021-02-11 12:07:13 EST
once more:
https://ci.eclipse.org/platform/job/eclipse.platform.resources-Gerrit/1494/testReport/junit/org.eclipse.core.tests.internal.localstore/AllTests/testWriteFile/
java.lang.NullPointerException
	at org.eclipse.core.tests.internal.localstore.FileSystemResourceManagerTest.write(FileSystemResourceManagerTest.java:472)
	at org.eclipse.core.tests.internal.localstore.FileSystemResourceManagerTest.testWriteFile(FileSystemResourceManagerTest.java:362)
Comment 9 Jörg Kubitz CLA 2021-02-11 12:24:49 EST
full stacktrace from log.txt:

!ENTRY org.eclipse.core.resources 4 0 2021-02-11 16:37:06.092
!MESSAGE exception occured during write of file: L/Project0/foo
!STACK 0
java.lang.NullPointerException
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.updateLocalSync(FileSystemResourceManager.java:1094)
	at org.eclipse.core.internal.localstore.FileSystemResourceManager.write(FileSystemResourceManager.java:1182)
	at org.eclipse.core.tests.internal.localstore.FileSystemResourceManagerTest$WriteFileContents.run(FileSystemResourceManagerTest.java:511)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2292)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2312)
	at org.eclipse.core.tests.internal.localstore.FileSystemResourceManagerTest.write(FileSystemResourceManagerTest.java:472)
	at org.eclipse.core.tests.internal.localstore.FileSystemResourceManagerTest.testWriteFile(FileSystemResourceManagerTest.java:362)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at junit.framework.TestCase.runTest(TestCase.java:177)
	at junit.framework.TestCase.runBare(TestCase.java:142)
	at junit.framework.TestResult$1.protect(TestResult.java:122)
	at junit.framework.TestResult.runProtected(TestResult.java:142)
	at junit.framework.TestResult.run(TestResult.java:125)
	at junit.framework.TestCase.run(TestCase.java:130)
	at junit.framework.TestSuite.runTest(TestSuite.java:241)
	at junit.framework.TestSuite.run(TestSuite.java:236)
	at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.junit.runners.Suite.runChild(Suite.java:128)
	at org.junit.runners.Suite.runChild(Suite.java:27)
	at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
	at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
	at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
	at org.junit.vintage.engine.execution.RunnerExecutor.execute(RunnerExecutor.java:43)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150)
	at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497)
	at org.junit.vintage.engine.VintageTestEngine.executeAllChildren(VintageTestEngine.java:82)
	at org.junit.vintage.engine.VintageTestEngine.execute(VintageTestEngine.java:73)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:108)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
	at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:96)
	at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:75)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:150)
	at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:124)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray2(ReflectionUtils.java:206)
	at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:161)
	at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:84)
	at org.eclipse.tycho.surefire.osgibooter.OsgiSurefireBooter.run(OsgiSurefireBooter.java:116)
	at org.eclipse.tycho.surefire.osgibooter.HeadlessTestApplication.start(HeadlessTestApplication.java:23)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:653)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:590)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1461)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1434)
Comment 10 Eclipse Genie CLA 2021-02-12 02:24:15 EST
New Gerrit change created: https://git.eclipse.org/r/c/platform/eclipse.platform.resources/+/176170