This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 59680 - NPE while invoking formEditorCookie.reloadForm()
Summary: NPE while invoking formEditorCookie.reloadForm()
Status: RESOLVED INVALID
Alias: None
Product: guibuilder
Classification: Unclassified
Component: Code (show other bugs)
Version: 4.x
Hardware: All All
: P1 blocker (vote)
Assignee: issues@guibuilder
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-06-07 02:48 UTC by Ayub Khan
Modified: 2005-06-07 10:02 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ayub Khan 2005-06-07 02:48:00 UTC
I have an application that tries to reload a form document like this

// Get the DataObject
DataObject dataObject=DataObject.find(file);
EditorCookie cookie=(EditorCookie)dataObject.getCookie(EditorCookie.class);	
if(cookie!=null)
{
  if(tmpcookie instanceof FormEditorSupport)
  {
     FormEditorSupport formCookie = (FormEditorSupport)tmpcookie;
     formCookie.reloadForm(); <--- NPE occurs here
  }

I get NPE on reloadForm() invocation, if the document is not opened.
This error does not happen if the document is open, while invoking reloadForm().
  

java.lang.NullPointerException
	at
org.netbeans.modules.form.FormEditorSupport.reloadDocument(FormEditorSupport.java:717)
	at
org.openide.text.CloneableEditorSupport.checkReload(CloneableEditorSupport.java:1744)
	at
org.openide.text.CloneableEditorSupport.access$1600(CloneableEditorSupport.java:79)
	at org.openide.text.CloneableEditorSupport$9.run(CloneableEditorSupport.java:2112)
	at org.netbeans.editor.BaseDocument.runAtomicAsUser(BaseDocument.java:1086)
	at org.netbeans.editor.GuardedDocument.runAtomic(GuardedDocument.java:217)
	at org.openide.text.NbDocument.runAtomic(NbDocument.java:341)
[catch] at
org.openide.text.CloneableEditorSupport$9.run(CloneableEditorSupport.java:2108)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:461)
	at
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
	at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Comment 1 Jan Stola 2005-06-07 10:02:40 UTC
Note that the form module doesn't have a public API and therefore it is not
recommended to depend on it - the implementation can change in any way without
notification.

Particularly the reloadForm() method is an implementation detail of the form
module and there is no contract that the method should satisfy. If you really want
to call it (in spite of the previous fact) it is up to you to ensure that
it is called in a valid context (e.g. don't invoke it on the forms that
are not opened).