Skip to content

rare NPE in classpath listener #966

Closed

Description

@martinlippert

It seems like I have hit a rare moment in time where the editor for the pom.xml file wasn't fully initialized yet when we tried to grab classpath information:

java.lang.NullPointerException: Cannot invoke "org.eclipse.ui.texteditor.ITextEditor.getAdapter(java.lang.Class)" because "this.sourcePage" is null
	at org.eclipse.m2e.editor.pom.MavenPomEditor.getAdapter(MavenPomEditor.java:1013)
	at org.springframework.tooling.ls.eclipse.commons.STS4LanguageClientImpl.lambda$9(STS4LanguageClientImpl.java:423)
	at org.springframework.tooling.jdt.ls.commons.classpath.ReusableClasspathListenerHandler$CallbackJob.lambda$0(ReusableClasspathListenerHandler.java:76)
	at java.base/java.lang.Iterable.forEach(Iterable.java:75)
	at org.springframework.tooling.jdt.ls.commons.classpath.ReusableClasspathListenerHandler$CallbackJob.run(ReusableClasspathListenerHandler.java:76)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

This is probably hard to reproduce. It happened when I created a Rest Service sample project right after starting up a fresh install of STS 4.17.2 with a fresh workspace, opened the pom.xml file, and pressed Yes on the reconcile popup - almost everything at the same time.

Activity

  1. added this to the 4.18.0.RELEASE milestone on Feb 1, 2023
  2. BoykoAlex commented on Feb 6, 2023

    @BoykoAlex
    Contributor

    It would have been best if MavenPomEditor doesn't throw an NPE in this case: eclipse-m2e/m2e-core#1235

    On our side i think we should catch and log exceptions without short-circuiting the loop: 5d9eee9

  3. BoykoAlex commented on Feb 6, 2023

    @BoykoAlex
    Contributor

    I'll close it. Also pushed logic to update code minings on classpath changed event only for editors for resources from classpath source folders. Thus, pom are filtered out (27e08f9). It looks like a fair assumption for the moment. Thus, pom editors are not applicable to this code any longer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

for: eclipsetheme: internal-architecturetype: bug

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions