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 48997 - CookieSet.getCookie may fail if used inside Node.getCookie
Summary: CookieSet.getCookie may fail if used inside Node.getCookie
Status: RESOLVED WONTFIX
Alias: None
Product: platform
Classification: Unclassified
Component: Nodes (show other bugs)
Version: 4.x
Hardware: All All
: P2 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-14 13:12 UTC by Jan Pokorsky
Modified: 2008-12-22 20:40 UTC (History)
1 user (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 Jan Pokorsky 2004-09-14 13:12:22 UTC
CS.getCookie sometimes returns null even if the
particular cookie exists. To reproduce this
misbehaviour it is necessary to use CS.getCookie
inside overridden Node.getCookie.

This regression caused issue #48595. If you
consider this as an intentional incompatible
change it should be highlighted in the upgrade
guide and in javadoc of Node and FilterNode since
it is pretty hard to detect what's going wrong.
Comment 1 Jaroslav Tulach 2004-09-14 17:57:02 UTC
Removing REGRESSION as this behaviour is present in 3.6. So it is not
regression anymore ;-)
Comment 2 Jaroslav Tulach 2004-09-23 08:06:25 UTC
This is a result of fix of issue 35856 - if the
getCookieSet().getCookie is called from a NodeLookup.lookupItem, it
knows that the real instance is not necessary and does not create it.
I am affraid that there would be performance implications (like
JavaEditor being created just by selecting a node in explorer) if I
remove that behaviour.

CCing performance guys to help us select the best solution.

Here is the illegalstateexception that shows the execution really
started from Lookup.lookupItem and the IllegalState is thrown because
the CookieSet returned null.
 org.netbeans.modules.java.ui.nodes.BridgeUtils.throwIllegalState(BridgeUtils.java:164)
org.netbeans.modules.java.ui.nodes.BridgeUtils.getElement(BridgeUtils.java:89)
org.netbeans.modules.java.ui.nodes.BridgeUtils.getClassElement(BridgeUtils.java:52)
org.netbeans.modules.java.ui.nodes.BridgeUtils.getElement(BridgeUtils.java:118)
org.netbeans.modules.java.ui.nodes.BridgeUtils.getElement(BridgeUtils.java:62)
org.netbeans.modules.java.ui.nodes.JavaSourceNodeFactory$CompatibleNode.getOldElement(JavaSourceNodeFactory.java:290)
org.netbeans.modules.java.ui.nodes.JavaSourceNodeFactory$CompatibleNode.getCookie(JavaSourceNodeFactory.java:265)
org.openide.nodes.NodeLookup.addCookie(NodeLookup.java:60)
org.openide.nodes.NodeLookup.updateLookupAsCookiesAreChanged(NodeLookup.java:122)
org.openide.nodes.NodeLookup.beforeLookup(NodeLookup.java:89)
org.openide.util.lookup.AbstractLookup.lookupItem(AbstractLookup.java:306)
org.openide.nodes.FilterNode$FilterLookup.lookupItem(FilterNode.java:1520)
org.openide.util.actions.CookieAction.resolveSupported(CookieAction.java:137)
org.openide.util.actions.CookieAction.doEnable(CookieAction.java:111)
org.openide.util.actions.CookieAction.enable(CookieAction.java:101)
org.openide.util.actions.NodeAction.isEnabled(NodeAction.java:121)
org.openide.awt.Actions$MenuBridge.updateState(Actions.java:625)
org.openide.awt.Actions$Bridge.propertyChange(Actions.java:350)
java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
org.openide.util.SharedClassObject.firePropertyChange(SharedClassObject.java:389)
org.openide.util.actions.NodeAction.maybeFireEnabledChange(NodeAction.java:258)
org.openide.util.actions.NodeAction$NodesL.forget(NodeAction.java:381)
org.openide.util.actions.NodeAction$NodesL.update(NodeAction.java:356)
org.openide.util.actions.NodeAction$NodesL.resultChanged(NodeAction.java:348)
org.openide.util.lookup.AbstractLookup.notifyListeners(AbstractLookup.java:405)
Comment 3 Jaroslav Tulach 2004-09-23 08:10:14 UTC
I guess that there is a simple workaround for this problem. If you
really want the instance of JavaEditor to be created all the time,
then do not ask for SourceCookie, but ask directly for JavaEditor, in
such case the extra communication between CookieSet and NodeLookup
will not take place as the cookie they are searching for will not match.

But as I said performance regressions are likely to appear if you
initialize JavaEditor all the time.