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 in XMLCompletions collectAttributeNameSuggestions() #719

Closed
fbricon opened this issue May 25, 2020 · 2 comments
Closed

NPE in XMLCompletions collectAttributeNameSuggestions() #719

fbricon opened this issue May 25, 2020 · 2 comments
Assignees
Labels
bug Something isn't working completion This issue or enhancement is related to completion support good first issue Good for newcomers
Milestone

Comments

@fbricon
Copy link
Contributor

fbricon commented May 25, 2020

Given:

<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" [
  <!ENTITY mdash "&#x2014;">
]>
<web-app a|>
  <display-name>Servlet 2.3 aWeb Application</display-name>
</web-app>

when typing an attribute in the web node, an NPE is thrown in XMLCompletions collectAttributeNameSuggestions():

[Error - 2:17:54 p.m.] May 25, 2020 02:17:54 org.eclipse.lemminx.services.XMLCompletions collectAttributeNameSuggestions()
Message: While performing ICompletionParticipant#onAttributeName
java.lang.NullPointerException
	at org.eclipse.lemminx.extensions.dtd.contentmodel.CMDTDDocument.findElementDeclaration(CMDTDDocument.java:164)
	at org.eclipse.lemminx.extensions.dtd.contentmodel.CMDTDDocument.findCMElement(CMDTDDocument.java:151)
	at org.eclipse.lemminx.extensions.contentmodel.model.ContentModelManager.findInternalCMElement(ContentModelManager.java:204)
	at org.eclipse.lemminx.extensions.contentmodel.model.ContentModelManager.findInternalCMElement(ContentModelManager.java:191)
	at org.eclipse.lemminx.extensions.contentmodel.participants.ContentModelCompletionParticipant.onAttributeName(ContentModelCompletionParticipant.java:263)
	at org.eclipse.lemminx.services.XMLCompletions.collectAttributeNameSuggestions(XMLCompletions.java:789)
	at org.eclipse.lemminx.services.XMLCompletions.doComplete(XMLCompletions.java:120)
	at org.eclipse.lemminx.services.XMLLanguageService.doComplete(XMLLanguageService.java:138)
	at org.eclipse.lemminx.XMLTextDocumentService.lambda$completion$1(XMLTextDocumentService.java:177)
	at java.base/java.util.concurrent.CompletableFuture.biApply(CompletableFuture.java:1307)
	at java.base/java.util.concurrent.CompletableFuture$BiApply.tryFire(CompletableFuture.java:1276)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(CompletableFuture.java:479)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:177)

Occurs in vscode-xml 0.11.0:

@fbricon fbricon added bug Something isn't working good first issue Good for newcomers completion This issue or enhancement is related to completion support labels May 25, 2020
@fbricon
Copy link
Contributor Author

fbricon commented May 25, 2020

The bug seems to be caused by the [<!ENTITY mdash "&#x2014;">] body of the DOCTYPE. It doesn't occur without it.

@fbricon fbricon added this to the 0.12.0 milestone May 25, 2020
@angelozerr
Copy link
Contributor

The bug seems to be caused by the [] body of the DOCTYPE. It doesn't occur without it.

Indeed there were a bug with Doctype subset (when it is not empty) but which have no ELEMENT declaration. The bug was that it created one CMElementDeclaration whith a null name. The PR #721 fixes this problem (no CMElementDeclaration are created when there are no ELEMENT declaration). This PR fixes all problem that we could have with CMElementDeclaration#getName() which could be null like #719 and #720

In otherwords this issue was fixed but I have written a test with this usecase in the PR #721

@fbricon fbricon closed this as completed May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working completion This issue or enhancement is related to completion support good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants