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 227461 - CESRedirector with GsfDataObject
Summary: CESRedirector with GsfDataObject
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Text (show other bugs)
Version: 7.4
Hardware: PC Solaris
: P3 normal (vote)
Assignee: Miloslav Metelka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-14 11:43 UTC by Andrew Krasny
Modified: 2013-04-12 14:53 UTC (History)
2 users (show)

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 Andrew Krasny 2013-03-14 11:43:22 UTC
The problem is visible as an NPE while new JavaScript File creation when there is registered CESRedirector.


java.lang.NullPointerException
	at org.openide.nodes.CookieSet.removeImpl(CookieSet.java:159)
	at org.openide.nodes.CookieSet.remove(CookieSet.java:153)
	at org.netbeans.modules.csl.core.GsfDataObject$GenericEditorSupport$Environment.removeSaveCookie(GsfDataObject.java:264)
	at org.netbeans.modules.csl.core.GsfDataObject$GenericEditorSupport.removeSaveCookie(GsfDataObject.java:302)
	at org.netbeans.modules.csl.core.GsfDataObject.setModified(GsfDataObject.java:127)



Actually there are several independent problems and fixing each of them could help.

Now when creating a JavaScript File from a template a GsfDataObject is created.
Then EditorModule.reformat() is applied, which causes invocation of file.getLookup().lookup(EditorCookie.class). This, in turn, creates GenericEditorSupport with a new GsfDataObject.Environment for the file. (Let's call it Support1)

Then setMIMEType() is invoked which asks CESRedirector for a  CloneableEditorSupport => a CloneableEditorSupport is created with a new GsfDataObject.Environment for the same file. (Let's call it Support2)

The problem is that later callNotifyModified() is invoked for Support1 but callNotifyUnmodified() is invoked for Support2.


Looks like there are several possible things to do:
1. remove local variable saveCookie from Environment. This will save us from the NPE. Cookie will be taken from javaData.getCookieSet() (And this seems to be a right thing to do anyway)
2. Maybe ask CESRedirector earlier. This will save us from two EditorSupports(?).
3. Maybe there should be no "modified" property changes during file creation? This will save us from add/removeSaveCookie during instantiation.
Comment 1 Svata Dedic 2013-04-03 09:21:29 UTC
Is the CESRedirector some standard one (= in which NB distribution) ?
Comment 2 Svata Dedic 2013-04-12 14:53:47 UTC
Well, I can reproduce the NullPointer, but the supplied CESRedirector seems to have a number of other issues - e.g. Form or PHP files do not open at all, Form files open sometimes (initially I did not get any file to open, later I do), initialization of hibernate mapping editor results in StackOverflow ... It seems the pattern used in the supplied cnd.cesredirector breaks assumptions throughout the IDE - I don't think it should be handled as a defect in a particular module. For the cases I saw, it causes creation of multiple EditorSupports per DataObject, and only the outermost actually 'wins' and will be used after the call.So it should be probably discussed whether it is OK that setMIMEType is called in the constructor - the partial instance will escape and is created recursively again.