To reproduce the problem:
(1) Open a Query Analyzer panel.
(2) Execute a valid SQL statement such as 'SELECT count(*) FROM a-valid-table'.
(3) An NPE similar to the one shown below is logged in the log file:
<2013-02-13 13:49:41,484> ERROR [AWT-EventQueue-0] <com.aquafold.aquaeditor.bridge.PaneFactory>
java.lang.NullPointerException
at com.aquafold.editor.standalone.api.PaneFactory.closedPane(PaneFactory.java:750)
at com.aquafold.aquaeditor.bridge.PaneFactory.closedPane(PaneFactory.java:45)
at com.aquafold.aquaeditor.bridge.PaneFactory.clearAndCloseEditorPane(PaneFactory.java:57)
at com.aquafold.datastudio.queryanalyzer.QueryPanel.clearAndCloseEditorPane(QueryPanel.java:2330)
at com.aquafold.datastudio.queryanalyzer.QueryPanel.createNewTextResultComponents(QueryPanel.java:2546)
at com.aquafold.datastudio.queryanalyzer.QueryPanel.createNewTextResults(QueryPanel.java:2518)
at com.aquafold.datastudio.queryanalyzer.QueryThread$6.run(QueryThread.java:399)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:646)
...
com.aquafold.aquaeditor.bridge.PaneFactory.closedPane(CEditorPane) caught the exception and logged it to the log file.
(4) Repeat (2) again, two more NPEs are logged.
Every time a statement is executed in the Query Analyzer panel, an Editor Pane will be recreated. I made change last night (SVN r31336 for issue #8187) so that when a new Editor Pane instance is created, PaneFactory.closedPane(old-editor-pane-instance) is called to close the old one (which to be thrown away). This editor pane is created as:
CEditorPane newPane = PaneFactory.getDefault().createNBEditorPane(CEditorPane, String mime);
bind popup menu to newPane;
newPane.disableUndo();
newPane.setText("");
Document d = newPane.getEditorKit().createDefaultDocument();
newPane.setDocument(d);
Is there anything missing here?
The NPE occurs because of the last two calls from the editor pane creation step:
Document d = newPane.getEditorKit().createDefaultDocument(); newPane.setDocument(d);
The Netbeans DataSystems API use the Document.StreamDescriptionProperty
document property to reference an internal DataObject instance which is essential for this API in order to work properly. This property is set inside the PaneFactory.getDefault().createNBEditorPane()
call, but then you set another document on the newPane
instance, and this default document doesn't have the Document.StreamDescriptionProperty
property set, therefore the reference to the DataObject instance is lost.
There is no need to set another document on the newPane
instance. Please remove the two calls listed above.
I removed the last two calls listed above upon creation of an editor pane.
In the current Query Panel implementation, there is also a case that an editor pane would create a new Document to replace the current Document as shown below:
// create a fresh document (without attached listeners)
Document newDoc = editorPane.getEditorKit().createDefaultDocument();
call other APIs to update the content of newDoc
editorPane.setDocument(newDoc)
In this case, an NPE is thrown when ADS invokes PaneFactory.closedPane(editorPane). I replaced above 3 lines with the followings
Document currentDoc = editorPane.getDocument()
call other APIs to update the content of currentDoc
to work around NPE problem. Let's see if this workaround would create any side-effect or not; if it does, PaneFactory likely should provide an API to change Document for an editor pane.
I removed the last two calls listed above upon creation of an editor pane.
In the current Query Panel implementation, there is also a case that an editor pane would create a new Document to replace the current Document as shown below:
// create a fresh document (without attached listeners)
Document newDoc = editorPane.getEditorKit().createDefaultDocument();
call other APIs to update the content of newDoc
editorPane.setDocument(newDoc)
In this case, an NPE is thrown when ADS invokes PaneFactory.closedPane(editorPane). I replaced above 3 lines with the followings
Document currentDoc = editorPane.getDocument()
call other APIs to update the content of currentDoc
to work around NPE problem. Let's see if this workaround would create any side-effect or not; if it does, PaneFactory likely should provide an API to change Document for an editor pane.
SVN r31398 - The editor pane created in a ResultsetTableView object may not be instantiated by PaneFactory. In this case, PaneFactory.closedPane(editorPane) should not be called upon closing the view.
SVN r31398 - The editor pane created in a ResultsetTableView object may not be instantiated by PaneFactory. In this case, PaneFactory.closedPane(editorPane) should not be called upon closing the view.
Issue #8345 |
Closed |
Fixed |
Resolved |
Completion |
No due date |
Fixed Build trunk/31398 |
No time estimate |
2 issue links |
relates to #9217
Issue #9217Performance problem with Text Results in 14.0 that didn't exist in 12.0 |
relates to #8187
Issue #8187Out of memory error |
The NPE occurs because of the last two calls from the editor pane creation step:
The Netbeans DataSystems API use the
Document.StreamDescriptionProperty
document property to reference an internal DataObject instance which is essential for this API in order to work properly. This property is set inside thePaneFactory.getDefault().createNBEditorPane()
call, but then you set another document on thenewPane
instance, and this default document doesn't have theDocument.StreamDescriptionProperty
property set, therefore the reference to the DataObject instance is lost.There is no need to set another document on the
newPane
instance. Please remove the two calls listed above.