Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE's on writing index #235

Closed
iloveeclipse opened this issue Jul 17, 2022 · 1 comment · Fixed by #237
Closed

NPE's on writing index #235

iloveeclipse opened this issue Jul 17, 2022 · 1 comment · Fixed by #237
Assignees
Labels
bug Something isn't working regression Something was broken by a previous change
Milestone

Comments

@iloveeclipse
Copy link
Member

Saw errors below during tests:

!ENTRY org.eclipse.jdt.core 4 4 2022-07-17 08:22:09.035
!MESSAGE Background Indexer Crash Recovery
!STACK 0
java.lang.NullPointerException: Cannot invoke "java.net.URI.toString()" because "this.uri" is null
	at org.eclipse.jdt.internal.core.index.IndexLocation.toString(IndexLocation.java:154)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.writeIndexMapFile(IndexManager.java:1484)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.addIndex(IndexManager.java:785)
	at org.eclipse.jdt.internal.core.search.indexing.AddJarFileToIndex.execute(AddJarFileToIndex.java:98)
	at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:478)
	at java.base/java.lang.Thread.run(Thread.java:833)
!ENTRY org.eclipse.jdt.core 1 0 2022-07-17 08:22:11.425
!MESSAGE SETUP testBug576433
Exception in thread "Java indexing" java.lang.NullPointerException: Cannot invoke "java.net.URI.toString()" because "this.uri" is null
	at org.eclipse.jdt.internal.core.index.IndexLocation.toString(IndexLocation.java:154)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.writeIndexMapFile(IndexManager.java:1484)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.addIndex(IndexManager.java:785)
	at org.eclipse.jdt.internal.core.search.indexing.AddJarFileToIndex.execute(AddJarFileToIndex.java:98)
	at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:478)
	at java.base/java.lang.Thread.run(Thread.java:833)

The root cause is that we don't set uri field if we can't parse URL in IndexLocation.

!ENTRY org.eclipse.jdt.core 4 4 2022-07-17 08:22:09.035
!MESSAGE Background Indexer Crash Recovery
!STACK 0
java.lang.NullPointerException: Cannot invoke "java.net.URI.toString()" because "this.uri" is null
	at org.eclipse.jdt.internal.core.index.IndexLocation.toString(IndexLocation.java:154)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.writeIndexMapFile(IndexManager.java:1484)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.addIndex(IndexManager.java:785)
	at org.eclipse.jdt.internal.core.search.indexing.AddJarFileToIndex.execute(AddJarFileToIndex.java:98)
	at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:478)
	at java.base/java.lang.Thread.run(Thread.java:833)

Looks like we don't properly convert Windows paths before:

!ENTRY org.eclipse.jdt.core 1 0 2022-07-17 08:22:06.335
!MESSAGE SETUP testIndexInJar

!ENTRY org.eclipse.jdt.core 4 4 2022-07-17 08:22:06.361
!MESSAGE Unexpected url to uri failure
!STACK 0
java.net.URISyntaxException: Illegal character in opaque part at index 11: jar:file:C:\workspaces\TestIndex.zip!/Test.index
	at java.base/java.net.URI$Parser.fail(URI.java:2974)
	at java.base/java.net.URI$Parser.checkChars(URI.java:3145)
	at java.base/java.net.URI$Parser.parse(URI.java:3181)
	at java.base/java.net.URI.<init>(URI.java:623)
	at java.base/java.net.URL.toURI(URL.java:1056)
	at org.eclipse.jdt.internal.core.index.IndexLocation.<init>(IndexLocation.java:86)
	at org.eclipse.jdt.internal.core.index.JarIndexLocation.<init>(JarIndexLocation.java:35)
	at org.eclipse.jdt.internal.core.index.IndexLocation.createIndexLocation(IndexLocation.java:55)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexLibrary(IndexManager.java:754)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexLibrary(IndexManager.java:722)
	at org.eclipse.jdt.internal.core.ClasspathChange.requestIndexing(ClasspathChange.java:577)
	at org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:2134)
	at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:501)
	at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:307)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:297)
	at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:160)
	at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:388)
	at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1514)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2394)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2405)
	at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:811)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3684)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3644)
	at org.eclipse.jdt.internal.core.JavaProject.setRawClasspath(JavaProject.java:3700)
	at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.setClasspath(AbstractJavaModelTests.java:3316)
	at org.eclipse.jdt.core.tests.model.JavaIndexTests.testIndexInJar(JavaIndexTests.java:801)
!ENTRY org.eclipse.jdt.core 1 0 2022-07-17 08:22:09.013
!MESSAGE SETUP testSharedIndexLocation

!ENTRY org.eclipse.jdt.core 4 4 2022-07-17 08:22:09.025
!MESSAGE Unexpected url to uri failure
!STACK 0
java.net.URISyntaxException: Illegal character in opaque part at index 7: file:C:\tmp\shared_index7104254713724521707\440334612.index
	at java.base/java.net.URI$Parser.fail(URI.java:2974)
	at java.base/java.net.URI$Parser.checkChars(URI.java:3145)
	at java.base/java.net.URI$Parser.parse(URI.java:3181)
	at java.base/java.net.URI.<init>(URI.java:623)
	at java.base/java.net.URL.toURI(URL.java:1056)
	at org.eclipse.jdt.internal.core.index.IndexLocation.<init>(IndexLocation.java:86)
	at org.eclipse.jdt.internal.core.index.FileIndexLocation.<init>(FileIndexLocation.java:34)
	at org.eclipse.jdt.internal.core.index.IndexLocation.createIndexLocation(IndexLocation.java:53)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexLibrary(IndexManager.java:754)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexLibrary(IndexManager.java:722)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexAll(IndexManager.java:708)
	at org.eclipse.jdt.internal.core.DeltaProcessor.updateIndex(DeltaProcessor.java:2733)
	at org.eclipse.jdt.internal.core.DeltaProcessor.updateCurrentDeltaAndIndex(DeltaProcessor.java:2600)
	at org.eclipse.jdt.internal.core.DeltaProcessor.traverseDelta(DeltaProcessor.java:2323)
	at org.eclipse.jdt.internal.core.DeltaProcessor.processResourceDelta(DeltaProcessor.java:1981)
	at org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:2155)
	at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:501)
	at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:307)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45)
	at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:297)
	at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:160)
	at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:388)
	at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1514)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2394)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2400)
	at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.createJavaProject(AbstractJavaModelTests.java:2314)
	at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.createJavaProject(AbstractJavaModelTests.java:1977)
	at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.createJavaProject(AbstractJavaModelTests.java:1780)
	at org.eclipse.jdt.core.tests.model.AbstractJavaModelTests.createJavaProject(AbstractJavaModelTests.java:1730)
	at org.eclipse.jdt.core.tests.model.JavaIndexTests.testSharedIndexLocation(JavaIndexTests.java:901)
@iloveeclipse
Copy link
Member Author

OK, in large parts https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/174169 was wrong and as side effect we have this NPE's and most likely org.eclipse.jdt.core.tests.model.JavaIndexTests.testIndexInJar failure on Windows (is there since 4.24).
URL's are not as strict as URI's but the code that supports such crazy constructs like jar:file: syntax (see org.eclipse.jdt.core.tests.model.JavaIndexTests.testIndexInJar()) is failing now.

This must be reverted in few places.

iloveeclipse added a commit to iloveeclipse/eclipse.jdt.core that referenced this issue Jul 17, 2022
In large parts https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/174169
was wrong and as side effect we have NPE's trying to persist jar index
location that has no valid URI and also
org.eclipse.jdt.core.tests.model.JavaIndexTests.testIndexInJar failure
on Windows (is there since 4.24).

URL's are not as strict as URI's but the code that supports such crazy
constructs like jar:file: syntax (see
org.eclipse.jdt.core.tests.model.JavaIndexTests.testIndexInJar()) is
failing now.

Revisited all places from original gerrit that changed URL to URI and
changed to something that actually works.

Fixes eclipse-jdt#235
iloveeclipse added a commit that referenced this issue Jul 17, 2022
In large parts https://git.eclipse.org/r/c/jdt/eclipse.jdt.core/+/174169
was wrong and as side effect we have NPE's trying to persist jar index
location that has no valid URI and also
org.eclipse.jdt.core.tests.model.JavaIndexTests.testIndexInJar failure
on Windows (is there since 4.24).

URL's are not as strict as URI's but the code that supports such crazy
constructs like jar:file: syntax (see
org.eclipse.jdt.core.tests.model.JavaIndexTests.testIndexInJar()) is
failing now.

Revisited all places from original gerrit that changed URL to URI and
changed to something that actually works.

Fixes #235
@iloveeclipse iloveeclipse self-assigned this Jul 17, 2022
@iloveeclipse iloveeclipse added bug Something isn't working regression Something was broken by a previous change labels Jul 17, 2022
@iloveeclipse iloveeclipse added this to the 4.25 M2 milestone Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working regression Something was broken by a previous change
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant