| Summary: | NPE when invoking content assist | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Modeling] TMF | Reporter: | Samantha Chan <chanskw> | ||||||
| Component: | Xtext | Assignee: | Project Inbox <tmf.xtext-inbox> | ||||||
| Status: | CLOSED WORKSFORME | QA Contact: | |||||||
| Severity: | major | ||||||||
| Priority: | P3 | CC: | sebastian.zarnekow, sven.efftinge | ||||||
| Version: | 1.0.1 | Flags: | sebastian.zarnekow:
indigo+
|
||||||
| Target Milestone: | M7 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Linux | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Created attachment 186582 [details]
Screen capture showing null entry in delta
This should never happen (see DirtyStateAwareResourceDescriptions.dirtyDescriptionsChanged). Did you delete any resources or files prior to saving the editor? (In reply to comment #2) > This should never happen (see > DirtyStateAwareResourceDescriptions.dirtyDescriptionsChanged). > Did you delete any resources or files prior to saving the editor? No, the procedure is like this: I edited the file with some invalid code - this causes validation to happens, and I see error markers created. Next, I deleted the problematic line. Save The file Invoke content assist. Please note that I need this fixed for XText 1.0.2 for my product. If this is possible, is there a way around this? Thanks! If you need me to look at anything to help debug this, please let me know. Created attachment 186649 [details]
screen cap showing empty resource map
The null entry is resulted because PersistableResourceDescriptionsImpl has an empty resourceDescriptionMap when getResourceDescription(uri) is called.
Is this expected? How can resourceDescriptionMap be empty?
Do you see any exceptions when #ensureLoaded is called for the first time? I'd assume there was something wrong with the persisted state. (In reply to comment #5) > Do you see any exceptions when #ensureLoaded is called for the first time? I'd > assume there was something wrong with the persisted state. No, there is no exception. However, the isLoaded flag is set to true, even when the map is empty. Samantha, did you try to bind your own GlobalScopeProvider and create a more robust FilterURIContainer or even wrap any given Container to not return null instances in #getResourceDescriptions? (In reply to comment #7) > Samantha, > > did you try to bind your own GlobalScopeProvider and create a more robust > FilterURIContainer or even wrap any given Container to not return null > instances in #getResourceDescriptions? Yes, I tried that, and that seems to work. Postponed until we have an idea on how to reproduce this issue. Please reopen this one if the problem persists or we'll have a reproducable example. Closed as cannot reproduce. Closing all bugs that were set to RESOLVED before Neon.0 Closing all bugs that were set to RESOLVED before Neon.0 |
Found this with XText 1.0.2/ I am not sure if this is a problem with my code, or something wrong with XText resource descriptions code. But I looked at this from my side, and cannot figure out what I did wrong, and suspect that this is related to the DirtyStateManager. In some cases, after I modify my file and save, the following stack trace happen. When this happens StateBaseContainer descriptionsChanged is given a "null" as the new resource description in the delta. Please see the first screen capture. Thread [main] (Suspended (breakpoint at line 80 in ResourceDescriptionsBasedContainer)) StateBasedContainer(ResourceDescriptionsBasedContainer).descriptionsChanged(IResourceDescription$Event) line: 80 DelegatingEventSource(AbstractResourceDescriptionChangeEventSource).notifyListeners(IResourceDescription$Event) line: 46 DelegatingEventSource.descriptionsChanged(IResourceDescription$Event) line: 33 DirtyStateAwareResourceDescriptions(AbstractResourceDescriptionChangeEventSource).notifyListeners(IResourceDescription$Event) line: 46 DirtyStateAwareResourceDescriptions.dirtyDescriptionsChanged(IResourceDescription$Event) line: 67 DirtyStateAwareResourceDescriptions$DirtyStateListener.descriptionsChanged(IResourceDescription$Event) line: 88 DirtyStateManager(AbstractResourceDescriptionChangeEventSource).notifyListeners(IResourceDescription$Event) line: 46 DirtyStateManager.notifyListeners(IDirtyResource, boolean) line: 95 DirtyStateManager.discardDirtyState(IDirtyResource) line: 54 DirtyStateEditorSupport.markEditorClean(DirtyStateEditorSupport$IDirtyStateEditorSupportClient) line: 280 NatureAddingEditorCallback(AbstractDirtyStateAwareEditorCallback).afterSave(XtextEditor) line: 45 CompoundXtextEditorCallback.afterSave(XtextEditor) line: 60 SPLEditor(XtextEditor).doSave(IProgressMonitor) line: 185 AbstractTextEditor$TextEditorSavable.doSave(IProgressMonitor) line: 7003 AbstractTextEditor$TextEditorSavable(Saveable).doSave(IProgressMonitor, IShellProvider) line: 214 SaveableHelper.doSaveModel(Saveable, IProgressMonitor, IShellProvider, boolean) line: 349 SaveableHelper$3.run(IProgressMonitor) line: 195 SaveableHelper$5.run(IProgressMonitor) line: 277 ModalContext.runInCurrentThread(IRunnableWithProgress, IProgressMonitor) line: 464 ModalContext.run(IRunnableWithProgress, boolean, IProgressMonitor, Display) line: 372 ApplicationWindow$1.run() line: 759 BusyIndicator.showWhile(Display, Runnable) line: 70 WorkbenchWindow(ApplicationWindow).run(boolean, boolean, IRunnableWithProgress) line: 756 WorkbenchWindow.run(boolean, boolean, IRunnableWithProgress) line: 2600 SaveableHelper.runProgressMonitorOperation(String, IRunnableWithProgress, IRunnableContext, IShellProvider) line: 285 SaveableHelper.runProgressMonitorOperation(String, IRunnableWithProgress, IWorkbenchWindow) line: 264 SaveableHelper.saveModels(ISaveablesSource, IWorkbenchWindow, boolean) line: 207 SaveableHelper.savePart(ISaveablePart, IWorkbenchPart, IWorkbenchWindow, boolean) line: 144 EditorManager.savePart(ISaveablePart, IWorkbenchPart, boolean) line: 1369 WorkbenchPage.savePart(ISaveablePart, IWorkbenchPart, boolean) line: 3334 WorkbenchPage.saveEditor(IEditorPart, boolean) line: 3347 SaveAction.run() line: 76 SaveAction(Action).runWithEvent(Event) line: 498 ActionHandler.execute(Map) line: 185 LegacyHandlerWrapper.execute(ExecutionEvent) line: 109 Command.executeWithChecks(ExecutionEvent) line: 476 ParameterizedCommand.executeWithChecks(Object, Object) line: 508 HandlerService.executeCommand(ParameterizedCommand, Event) line: 169 WorkbenchKeyboard.executeCommand(Binding, Event) line: 468 WorkbenchKeyboard.press(List, Event) line: 786 WorkbenchKeyboard.processKeyEvent(List, Event) line: 885 WorkbenchKeyboard.filterKeySequenceBindings(Event) line: 567 WorkbenchKeyboard.access$3(WorkbenchKeyboard, Event) line: 508 WorkbenchKeyboard$KeyDownFilter.handleEvent(Event) line: 123 EventTable.sendEvent(Event) line: 84 Display.filterEvent(Event) line: 1524 StyledText(Widget).sendEvent(Event) line: 1257 StyledText(Widget).sendEvent(int, Event, boolean) line: 1282 StyledText(Widget).sendEvent(int, Event) line: 1267 StyledText(Widget).sendKeyEvent(int, GdkEventKey) line: 1294 StyledText(Widget).gtk_key_press_event(int, int) line: 730 StyledText(Control).gtk_key_press_event(int, int) line: 2841 StyledText(Composite).gtk_key_press_event(int, int) line: 734 StyledText(Widget).windowProc(int, int, int) line: 1743 StyledText(Control).windowProc(int, int, int) line: 4796 Display.windowProc(int, int, int) line: 4360 OS._gtk_main_do_event(int) line: not available [native method] OS.gtk_main_do_event(int) line: 8189 Display.eventProc(int, int) line: 1238 OS._g_main_context_iteration(int, boolean) line: not available [native method] OS.g_main_context_iteration(int, boolean) line: 2237 Display.readAndDispatch() line: 3159 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2640 Workbench.runUI() line: 2604 Workbench.access$4(Workbench) line: 2438 Workbench$7.run() line: 671 Realm.runWithDefault(Realm, Runnable) line: 332 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 664 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149 IDEApplication.start(IApplicationContext) line: 115 EclipseAppHandle.run(Object) line: 196 EclipseAppLauncher.runApplication(Object) line: 110 EclipseAppLauncher.start(Object) line: 79 EclipseStarter.run(Object) line: 369 EclipseStarter.run(String[], Runnable) line: 179 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 48 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 600 Main.invokeFramework(String[], URL[]) line: 620 Main.basicRun(String[]) line: 575 Main.run(String[]) line: 1408 Main.main(String[]) line: 1384 This causes uriToDescription from StateBasedContiainer to contain a null value for the URI provided by the delta. This code does not check for null value: public void descriptionsChanged(IResourceDescription.Event event) { if (uriToDescription != null) { for(IResourceDescription.Delta delta: event.getDeltas()) { if (uriToDescription.containsKey(delta.getUri())) { uriToDescription.put(delta.getUri(), delta.getNew()); } } } } After this happen, I try to invoke content assist from the file, and will always get a NPE popped up. This is where the NPE happens. This NPE happens because in the globalScopeProvider.createContainerScope method, the code checks if content is empty: protected IScope createContainerScope(IScope parent, IContainer container, EReference reference) { Iterable<IResourceDescription> content = container.getResourceDescriptions(); if (Iterables.isEmpty(content)) return parent; return new ContainerBasedScope(parent, reference, container); } In this case, the content is not empty, however, uriToDescriptions contains an entry where the uri is the key, but the value is null. This is where it blows up in FilterUriContainer: public Iterable<IResourceDescription> getResourceDescriptions() { return Iterables.filter(delegate.getResourceDescriptions(), new Predicate<IResourceDescription>() { public boolean apply(IResourceDescription input) { return !input.getURI().equals(filterMe); // NPE HERE, AS INPUT IS NULL. } }); } Thread [main] (Suspended (exception NullPointerException)) FilterUriContainer$1.apply(IResourceDescription) line: 33 FilterUriContainer$1.apply(Object) line: 1 Iterators$8.computeNext() line: 564 Iterators$8(AbstractIterator<T>).tryToComputeNext() line: 132 Iterators$8(AbstractIterator<T>).hasNext() line: 127 Iterables.isEmpty(Iterable<T>) line: 767 SPLGlobalScopeProvider.createContainerScope(IScope, IContainer, EReference) line: 92 SPLGlobalScopeProvider(DefaultGlobalScopeProvider).createContainerScopeWithContext(EObject, IScope, IContainer, EReference) line: 95 SPLGlobalScopeProvider(DefaultGlobalScopeProvider).getScope(EObject, EReference) line: 51 SPLGlobalScopeProvider.getWorkspaceScope(EObject, EReference) line: 43 SPLGlobalScopeProvider.getScope(EObject, EReference) line: 35 SPLImportedNamespaceLocalScopeProvider(AbstractGlobalScopeDelegatingScopeProvider).getGlobalScope(EObject, EReference) line: 32 SPLImportedNamespaceLocalScopeProvider.doGetGlobalScope(EObject, EReference) line: 375 SPLImportedNamespaceLocalScopeProvider.getScope(EObject, EReference) line: 99 SPLImportedNamespaceLocalScopeProvider.getScope(EObject, EReference) line: 102 SPLImportedNamespaceLocalScopeProvider.getScope(EObject, EReference) line: 102 SPLImportedNamespaceLocalScopeProvider.getScope(EObject, EReference) line: 102 SPLScopeProvider(AbstractDeclarativeScopeProvider).delegateGetScope(EObject, EReference) line: 72 SPLScopeProvider(AbstractDeclarativeScopeProvider).getScope(EObject, EReference) line: 102 AbstractJavaBasedContentProposalProvider$ReferenceProposalCreator.lookupCrossReference(EObject, EReference, ICompletionProposalAcceptor, Predicate<IEObjectDescription>, Function<IEObjectDescription,ICompletionProposal>) line: 95 SPLProposalProvider(AbstractJavaBasedContentProposalProvider).lookupCrossReference(EObject, EReference, ICompletionProposalAcceptor, Predicate<IEObjectDescription>, Function<IEObjectDescription,ICompletionProposal>) line: 192 SPLProposalProvider(AbstractJavaBasedContentProposalProvider).lookupCrossReference(CrossReference, EReference, ContentAssistContext, ICompletionProposalAcceptor, Predicate<IEObjectDescription>) line: 186 SPLProposalProvider(AbstractJavaBasedContentProposalProvider).lookupCrossReference(CrossReference, ContentAssistContext, ICompletionProposalAcceptor, Predicate<IEObjectDescription>) line: 166 SPLProposalProvider(AbstractJavaBasedContentProposalProvider).lookupCrossReference(CrossReference, ContentAssistContext, ICompletionProposalAcceptor) line: 153 SPLProposalProvider(AbstractSPLProposalProvider).completeTypeRef_Referenced(EObject, Assignment, ContentAssistContext, ICompletionProposalAcceptor) line: 671 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 48 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 600 AbstractJavaBasedContentProposalProvider$1(PolymorphicDispatcher<RT>).invoke(Object...) line: 272 SPLProposalProvider(AbstractJavaBasedContentProposalProvider).invokeMethod(String, ICompletionProposalAcceptor, Object...) line: 229 SPLProposalProvider(AbstractJavaBasedContentProposalProvider).completeAssignment(Assignment, ContentAssistContext, ICompletionProposalAcceptor) line: 148 AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.caseAssignment(Assignment) line: 67 AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.caseAssignment(Assignment) line: 1 AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch(XtextSwitch<T>).doSwitch(int, EObject) line: 164 AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch(XtextSwitch<T>).doSwitch(EClass, EObject) line: 70 AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch(XtextSwitch<T>).doSwitch(EObject) line: 58 AbstractContentProposalProvider$DefaultContentAssistProcessorSwitch.accept(AbstractElement) line: 72 SPLProposalProvider(AbstractContentProposalProvider).createProposals(ContentAssistContext, ICompletionProposalAcceptor) line: 109 SPLProposalProvider(AbstractJavaBasedContentProposalProvider).createProposals(ContentAssistContext, ICompletionProposalAcceptor) line: 205 SPLProposalProvider.createProposals(ContentAssistContext, ICompletionProposalAcceptor) line: 220 CompletionProposalComputer.exec(XtextResource) line: 51 CompletionProposalComputer.exec(Object) line: 1 XtextDocument$XtextDocumentLocker(IStateAccess$AbstractImpl<P>).readOnly(IUnitOfWork<T,P>) line: 40 XtextDocument.readOnly(IUnitOfWork<T,XtextResource>) line: 70 XtextContentAssistProcessor.computeCompletionProposals(ITextViewer, int) line: 79 ContentAssistant.computeCompletionProposals(ITextViewer, int) line: 1834 CompletionProposalPopup.computeProposals(int) line: 556 CompletionProposalPopup.access$16(CompletionProposalPopup, int) line: 553 CompletionProposalPopup$2.run() line: 488 BusyIndicator.showWhile(Display, Runnable) line: 70 CompletionProposalPopup.showProposals(boolean) line: 482 ContentAssistant.showPossibleCompletions() line: 1660 XtextSourceViewer(SourceViewer).doOperation(int) line: 919 XtextSourceViewer(ProjectionViewer).doOperation(int) line: 1534 ContentAssistAction$1.run() line: 82 BusyIndicator.showWhile(Display, Runnable) line: 70 ContentAssistAction.run() line: 80 ContentAssistAction(Action).runWithEvent(Event) line: 498 ActionHandler.execute(Map) line: 185 LegacyHandlerWrapper.execute(ExecutionEvent) line: 109 Command.executeWithChecks(ExecutionEvent) line: 476 ParameterizedCommand.executeWithChecks(Object, Object) line: 508 HandlerService.executeCommand(ParameterizedCommand, Event) line: 169 WorkbenchKeyboard.executeCommand(Binding, Event) line: 468 WorkbenchKeyboard.press(List, Event) line: 786 WorkbenchKeyboard.processKeyEvent(List, Event) line: 885 WorkbenchKeyboard.filterKeySequenceBindings(Event) line: 567 WorkbenchKeyboard.access$3(WorkbenchKeyboard, Event) line: 508 WorkbenchKeyboard$KeyDownFilter.handleEvent(Event) line: 123 EventTable.sendEvent(Event) line: 84 Display.filterEvent(Event) line: 1524 StyledText(Widget).sendEvent(Event) line: 1257 StyledText(Widget).sendEvent(int, Event, boolean) line: 1282 StyledText(Widget).sendEvent(int, Event) line: 1267 StyledText(Widget).sendKeyEvent(int, GdkEventKey) line: 1294 StyledText(Widget).gtk_key_press_event(int, int) line: 730 StyledText(Control).gtk_key_press_event(int, int) line: 2841 StyledText(Composite).gtk_key_press_event(int, int) line: 734 StyledText(Widget).windowProc(int, int, int) line: 1743 StyledText(Control).windowProc(int, int, int) line: 4796 Display.windowProc(int, int, int) line: 4360 OS._gtk_main_do_event(int) line: not available [native method] OS.gtk_main_do_event(int) line: 8189 Display.eventProc(int, int) line: 1238 OS._g_main_context_iteration(int, boolean) line: not available [native method] OS.g_main_context_iteration(int, boolean) line: 2237 Display.readAndDispatch() line: 3159 Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2640 Workbench.runUI() line: 2604 Workbench.access$4(Workbench) line: 2438 Workbench$7.run() line: 671 Realm.runWithDefault(Realm, Runnable) line: 332 Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 664 PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149 IDEApplication.start(IApplicationContext) line: 115 EclipseAppHandle.run(Object) line: 196 EclipseAppLauncher.runApplication(Object) line: 110 EclipseAppLauncher.start(Object) line: 79 EclipseStarter.run(Object) line: 369 EclipseStarter.run(String[], Runnable) line: 179 NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method] NativeMethodAccessorImpl.invoke(Object, Object[]) line: 48 DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25 Method.invoke(Object, Object...) line: 600 Main.invokeFramework(String[], URL[]) line: 620 Main.basicRun(String[]) line: 575 Main.run(String[]) line: 1408 Main.main(String[]) line: 1384 Sorry for the long stack trace, but I do not know how else to describe this. Please advise.