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

Nullpointer Exception in catalog extension #833

Closed
deathaxe opened this issue Aug 1, 2020 · 6 comments · Fixed by #838
Closed

Nullpointer Exception in catalog extension #833

deathaxe opened this issue Aug 1, 2020 · 6 comments · Fixed by #838
Labels
bug Something isn't working
Milestone

Comments

@deathaxe
Copy link

deathaxe commented Aug 1, 2020

If the client doesn't send the xml.catalog: [] array setting explicitly upon initialization, the following Nullpointer exception is raised by the Arrays.stream().

lemminx: Aug 01, 2020 3:17:00 PM org.eclipse.lemminx.XMLLanguageServer initialize
lemminx: INFORMATION: Initializing XML Language server
lemminx: LemMinX Server info:
lemminx:  - Version : 0.13.1
lemminx:  - Java : C:\Program Files\Java\jre1.8.0_251
lemminx:  - Git 3c6c0de - [maven-release-plugin] prepare release 0.13.1
lemminx: Aug 01, 2020 3:17:00 PM org.eclipse.lemminx.services.extensions.XMLExtensionsRegistry registerExtension
lemminx: SCHWERWIEGEND: Error while initializing extension <org.eclipse.lemminx.extensions.catalog.XMLCatalogPlugin>
lemminx: java.lang.NullPointerException
lemminx: 	at java.util.Arrays.stream(Unknown Source)
lemminx: 	at org.eclipse.lemminx.extensions.catalog.XMLCatalogPlugin.validateCatalogPaths(XMLCatalogPlugin.java:70)
lemminx: 	at org.eclipse.lemminx.extensions.catalog.XMLCatalogPlugin.doSave(XMLCatalogPlugin.java:47)
lemminx: 	at org.eclipse.lemminx.services.extensions.XMLExtensionsRegistry.registerExtension(XMLExtensionsRegistry.java:201)
lemminx: 	at org.eclipse.lemminx.services.extensions.XMLExtensionsRegistry.lambda$initialize$2(XMLExtensionsRegistry.java:191)
lemminx: 	at java.lang.Iterable.forEach(Unknown Source)
lemminx: 	at org.eclipse.lemminx.services.extensions.XMLExtensionsRegistry.initialize(XMLExtensionsRegistry.java:190)
lemminx: 	at org.eclipse.lemminx.services.extensions.XMLExtensionsRegistry.initializeIfNeeded(XMLExtensionsRegistry.java:180)
lemminx: 	at org.eclipse.lemminx.services.extensions.XMLExtensionsRegistry.getDiagnosticsParticipants(XMLExtensionsRegistry.java:132)
lemminx: 	at org.eclipse.lemminx.services.XMLDiagnostics.doExtensionsDiagnostics(XMLDiagnostics.java:83)
lemminx: 	at org.eclipse.lemminx.services.XMLDiagnostics.doDiagnostics(XMLDiagnostics.java:53)
lemminx: 	at org.eclipse.lemminx.services.XMLLanguageService.doDiagnostics(XMLLanguageService.java:159)
lemminx: 	at org.eclipse.lemminx.services.XMLLanguageService.publishDiagnostics(XMLLanguageService.java:168)
lemminx: 	at org.eclipse.lemminx.XMLTextDocumentService.validate(XMLTextDocumentService.java:466)
lemminx: 	at org.eclipse.lemminx.XMLTextDocumentService.lambda$triggerValidationFor$23(XMLTextDocumentService.java:459)
lemminx: 	at java.util.concurrent.CompletableFuture.uniAccept(Unknown Source)
lemminx: 	at java.util.concurrent.CompletableFuture$UniAccept.tryFire(Unknown Source)
lemminx: 	at java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
lemminx: 	at java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
lemminx: 	at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(Unknown Source)
lemminx: 	at java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
lemminx: 	at java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)

The ContentModelSettings object should return safe defaults if no catalog is present (empty array instead of null) or validateCatalogPaths() should handle the null return value properly.

@angelozerr
Copy link
Contributor

@deathaxe is there any chance to have a PR for that? If you wish to do that you need to sign your Eclipse CLA

@deathaxe
Copy link
Author

deathaxe commented Aug 6, 2020

I don't have JDK installed and don't intend to start developing in Java anytime soon.

@angelozerr
Copy link
Contributor

angelozerr commented Aug 7, 2020

I don't have JDK installed and don't intend to start developing in Java anytime soon.

Ok thanks for your answer.

@datho7561 could you take care of this issue please.

datho7561 added a commit to datho7561/lemminx that referenced this issue Aug 7, 2020
Fixes eclipse#833

To test, checkout vscode-xml, remove the default value for `xml.catalog`
in the package.json, then launch with the patched language server.
No NPE should be reported.

Signed-off-by: David Thompson <davthomp@redhat.com>
@angelozerr angelozerr added the bug Something isn't working label Aug 10, 2020
@angelozerr angelozerr added this to the 0.13.2 milestone Aug 10, 2020
angelozerr pushed a commit that referenced this issue Aug 10, 2020
Fixes #833

To test, checkout vscode-xml, remove the default value for `xml.catalog`
in the package.json, then launch with the patched language server.
No NPE should be reported.

Signed-off-by: David Thompson <davthomp@redhat.com>
@fbricon
Copy link
Contributor

fbricon commented Aug 10, 2020

@angelozerr @datho7561 we need to check other properties are handled safely too

@angelozerr
Copy link
Contributor

@angelozerr @datho7561 we need to check other properties are handled safely too

I think it's was the only settings which thrown problem.

@datho7561
Copy link
Contributor

@fbricon I double checked. After this PR, no NPE will occur when launching the server with no configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants