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

Summary: NPE while invoking formEditorCookie.reloadForm()
Product: guibuilder Reporter: Ayub Khan <ayubskhan>
Component: CodeAssignee: issues@guibuilder <issues>
Status: RESOLVED INVALID    
Severity: blocker    
Priority: P1    
Version: 4.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

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).