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

LSP client: Prevent NullPointerException when caret is not present on text component #5393

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

matthiasblaesing
Copy link
Contributor

Observed exception:

java.lang.NullPointerException: Cannot invoke "javax.swing.text.Caret.getDot()" because "this.caret" is null
            at java.desktop/javax.swing.text.JTextComponent.getCaretPosition(JTextComponent.java:1704)
            at org.netbeans.modules.lsp.client.bindings.MarkOccurrences.<init>(MarkOccurrences.java:71)
            at org.netbeans.modules.lsp.client.bindings.TextDocumentSyncServerCapabilityHandler.lambda$registerBackgroundTasks$6(TextDocumentSyncServerCapabilityHandler.java:330)
            at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
            at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
            at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
            at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
            at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
            at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
            at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
            at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
[catch] at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
            at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
            at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
            at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
            at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
            at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

The fix is similar to this fix:
22f5827

@matthiasblaesing matthiasblaesing added the TypeScript [ci] enable web job label Jan 30, 2023
@matthiasblaesing matthiasblaesing added this to the NB18 milestone Jan 30, 2023
@neilcsmith-net
Copy link
Member

Any reason not to target delivery?

@matthiasblaesing
Copy link
Contributor Author

@neilcsmith-net no real one. I was not planning to get this into 17. It is not a regression and exists since a long time. I can rebase it onto delivery though.

@neilcsmith-net
Copy link
Member

I'll leave it up to you. Seems a low risk fix for an annoyance? Will sync for 17-rc3 tomorrow if you do want it in.

Observed exception:

java.lang.NullPointerException: Cannot invoke "javax.swing.text.Caret.getDot()" because "this.caret" is null
            at java.desktop/javax.swing.text.JTextComponent.getCaretPosition(JTextComponent.java:1704)
            at org.netbeans.modules.lsp.client.bindings.MarkOccurrences.<init>(MarkOccurrences.java:71)
            at org.netbeans.modules.lsp.client.bindings.TextDocumentSyncServerCapabilityHandler.lambda$registerBackgroundTasks$6(TextDocumentSyncServerCapabilityHandler.java:330)
            at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
            at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:771)
            at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:722)
            at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:716)
            at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
            at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
            at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:741)
            at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:136)
[catch] at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
            at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
            at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
            at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
            at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
            at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
@matthiasblaesing matthiasblaesing changed the base branch from master to delivery January 31, 2023 17:34
@apache apache locked and limited conversation to collaborators Jan 31, 2023
@apache apache unlocked this conversation Jan 31, 2023
@matthiasblaesing matthiasblaesing added the kind:bug Bug report or fix label Jan 31, 2023
@matthiasblaesing matthiasblaesing modified the milestones: NB18, NB17 Jan 31, 2023
@matthiasblaesing
Copy link
Contributor Author

@neilcsmith-net as suggested I rebased, did a quick smoke test locally, force pushed and tests are green. I retargeted this to delivery. If still fine, it would be nice to get it in. Thank you.

@jlahoda
Copy link
Contributor

jlahoda commented Jan 31, 2023

Hopefully OK.

@matthiasblaesing
Copy link
Contributor Author

Hopefully OK.

Thank you - you made me laught 🥲

@neilcsmith-net
Copy link
Member

Thanks @matthiasblaesing merging now.

@neilcsmith-net neilcsmith-net merged commit ec09f98 into apache:delivery Feb 1, 2023
@matthiasblaesing matthiasblaesing deleted the npe_lsp branch February 4, 2023 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug Bug report or fix TypeScript [ci] enable web job
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants