PreviousNextTracker indexSee it online !

(7/211) 2662 - [4.3] NPE when loading caret infos

Hi, I opened a file and got this exception

It seems that one Selection in the Selection\[\] array is
null but I cannot understand how it is possible, if
anyone has an idea ...

\[error\] WorkThread: Exception in AWT thread:
\[error\] WorkThread: java.lang.NullPointerException
\[error\] WorkThread: at
org.gjt.sp.jedit.EditPane.loadCaretInfo(EditPane.java:367)
\[error\] WorkThread: at
org.gjt.sp.jedit.EditPane$2.run(EditPane.java:164)
\[error\] WorkThread: at
org.gjt.sp.util.WorkThreadPool.doAWTRequest(WorkThreadPool.java:392)
\[error\] WorkThread: at
org.gjt.sp.util.WorkThreadPool.doAWTRequests(WorkThreadPool.java:380)
\[error\] WorkThread: at
org.gjt.sp.util.WorkThreadPool.access$200(WorkThreadPool.java:37)
\[error\] WorkThread: at
org.gjt.sp.util.WorkThreadPool$RunRequestsInAWTThread.run(WorkThreadPool.java:477)
\[error\] WorkThread: at
java.awt.event.InvocationEvent.dispatch(Unknown Source)
\[error\] WorkThread: at
java.awt.EventQueue.dispatchEvent(Unknown Source)
\[error\] WorkThread: at
java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown
Source)
\[error\] WorkThread: at
java.awt.EventDispatchThread.pumpEventsForFilter(Unknown
Source)
\[error\] WorkThread: at
java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown
Source)
\[error\] WorkThread: at
java.awt.EventDispatchThread.pumpEvents(Unknown Source)
\[error\] WorkThread: at
java.awt.EventDispatchThread.pumpEvents(Unknown Source)
\[error\] WorkThread: at
java.awt.EventDispatchThread.run(Unknown Source)

Submitted kpouer - 2006-09-13 14:26:16 Assigned
Priority 5 Labels editor core
Status open Group None
Resolution None

Comments

2008-02-27 21:58:22
kpouer

- **status**: open --> closed-works-for-me

2008-02-27 21:58:22
kpouer

Logged In: YES
user_id=285591
Originator: YES

It never happened again

2009-12-29 14:34:45
kpouer

- **labels**: --> editor core
- **summary**: NPE when loading caret infos --> [4.3] NPE when loading caret infos
- **status**: closed-works-for-me --> open

2009-12-29 14:34:45
kpouer

Oh it happened again when I opened a file, still no hint about it, on 4.3 final

java.lang.NullPointerException
at org.gjt.sp.jedit.EditPane.loadCaretInfo(EditPane.java:416)
at org.gjt.sp.jedit.EditPane$2.run(EditPane.java:216)
at org.gjt.sp.util.WorkThreadPool.doAWTRequest(WorkThreadPool.java:398)
at org.gjt.sp.util.WorkThreadPool.doAWTRequests(WorkThreadPool.java:383)
at org.gjt.sp.util.WorkThreadPool.access$200(WorkThreadPool.java:37)
at org.gjt.sp.util.WorkThreadPool$RunRequestsInAWTThread.run(WorkThreadPool.java:483)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

2009-12-29 21:20:28
*anonymous

Do you know if the file you opened was previously opened in jEdit in the same session?

2009-12-30 05:14:04
*anonymous

I have some crazy idea. The SelectionManager is not a synchronized class, and its correctness relies on the fact that all changes to it are made from the GUI thread. Can there be any background threads that were created by plugins as a response to opening the file and that may change the selection? Then, possibly between the time the local selection array is created and the time it is filled, one of the selections may become null.

2009-12-30 07:57:44
*anonymous

I think that it doesn't have to be a plugin. Some background tasks initiated by the core (e.g. Search and Replace in files) can also change the selection, while in the GUI thread it might try to load the caret info for them.
I think that making the selection manager synchronized can solve this issue. I don't know if it will visibly affect performance.