eclipse-xtext / eclipse-xtext/xtext
NPE possible in org.eclipse.xtext.resource.containers.StateBasedContainerManager#internalGetContainerHandle
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 831
- Forks
- 330
- Avg merge
- 3d 7h
- Merged PRs (30d)
- 12
Description
internalGetContainerHandle assumes desc is always nonNull. I have a case where that isn't true (not certain why - I'm still debugging that). If that assumption is deliberate, I suggest adding a comment documenting the assumption and/or adding a throws statement so users know what to expect. If it isn't deliberate, I suggest adding a null pointer check somewhere.
My particular error comes in the middle of code I modified from Lorenzo Bettini's Xtext/XTend book (2nd Edition) - in the SmallJava examaple. Specifically this code:
@Inject ResourceDescriptionsProvider rdp
@Inject IContainer.Manager cm
....
def getVisibleContainers(EObject o) {
val index = rdp.getResourceDescriptions(o.eResource)
val rd = index.getResourceDescription(o.eResource.URI)
cm.getVisibleContainers(rd, index)
}
Apparently the value of rd is null - thus causing the NPE when it gets into internalGetContainerHandle inside the getVisibleContainers call.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in org.eclipse.xtext/src/org/eclipse/xtext/resource/containers/StateBasedContainerManager.java at internalGetContainerHandle and inspect how getVisibleContainers passes its resource description. Reproduce the supplied SmallJava example, where getResourceDescription may return null, and determine the intended null contract. Done means the behavior is documented or safely handled with a regression test for the reported path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100