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 34155 - Project-specific settings do not work reliably
Summary: Project-specific settings do not work reliably
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 3.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: David Konecny
URL:
Keywords: REGRESSION, SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2003-06-04 16:05 UTC by Jesse Glick
Modified: 2008-12-22 17:46 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Module (JAR) with a project-specific option and an action to display it in a nonmodal dialog (11.37 KB, application/octet-stream)
2003-06-04 16:06 UTC, Jesse Glick
Details
Steps to exercise the module and demonstrate the problem (1.12 KB, text/plain)
2003-06-04 16:07 UTC, Jesse Glick
Details
NB 3.4.1 version of the module (11.37 KB, application/octet-stream)
2003-06-04 16:31 UTC, Jesse Glick
Details
NB 3.3.2 version of the module; note - Options link is broken, so to see Options-like view of option, unhide SFS in Filesystems Settings, then look under Default System -> Services (11.29 KB, application/octet-stream)
2003-06-04 16:32 UTC, Jesse Glick
Details
binary patch (32.39 KB, application/octet-stream)
2003-06-05 16:02 UTC, David Konecny
Details
source code patch (1.44 KB, patch)
2003-06-05 16:02 UTC, David Konecny
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2003-06-04 16:05:35 UTC
Try placing the attached module (source included
in JAR) in the modules directory of a fresh NB 3.5
RC2 installation, and follow the attached steps.
The project-specific setting does not work
reliably; its value is not consistently saved
after changes, nor is its value consistently read
after switching projects. It seems that opening
the Options window improves its behavior, at least
for a time, so that these two things work.
Presence or absence of the magic isGlobal method
has no apparent effect on the behavior; the
attached JAR has the method, but the problem can
be seen without it too. This problem does not
appear to be timing-related but I am not sure.

Expected behavior:

1. The Options dialog when open should always show
the same values as the test dialog when open.
[Observed, but the mere act of opening Options
sometimes changed the value in both]

2. Every time a setting value is changed, whether
from Options or the test dialog, writeExternal
should be called on the bean (after a few seconds
delay), indicating that it is being saved.
[Sometimes observed but not until Options was opened]

3. The value in a newly-created project should be
the same as in the last-opened project, with no
readExternal. [Observed]

4. Changes made in a project should never be
visible in other existing projects. [Sometimes
observed but not until Options was opened]

5. Switching projects should immediately change
the visible value in the test dialog, with
readExternal being called. [Sometimes observed but
not until Options was opened]

The SystemOption here is pretty simple; I can't
see anything odd about it. The dialog simply
displays its values in r/w mode and uses a
property change listener to display external
changes in the settings.
Comment 1 Jesse Glick 2003-06-04 16:06:29 UTC
Created attachment 10587 [details]
Module (JAR) with a project-specific option and an action to display it in a nonmodal dialog
Comment 2 Jesse Glick 2003-06-04 16:07:10 UTC
Created attachment 10588 [details]
Steps to exercise the module and demonstrate the problem
Comment 3 Jesse Glick 2003-06-04 16:17:36 UTC
In NB 3.4.1 (change OpenIDE-Module-IDE-Dependencies to be 2.23.2), it
is similar, but in step 17, prop1 stays as foo and rE is not called -
i.e. it is slightly more broken.

Comment 4 Jesse Glick 2003-06-04 16:31:11 UTC
In NB 3.3.2, push IDE dep back to 1.43.3. Also comment out
ProbeAction.iconResource, and use (Frame)null in place of
WindowManager.getDefault().getMainWindow() in UsingSettingsThing's
super constructor.

3.3.2 has some problems too - mainly, that changes to the bean in p2
are not written out until you view its BeanNode in the Services/
folder of the SFS (the .shadow is broken in 3.3.2 due to the newer
syntax used here); but after that it works better.

So I guess the summary is: it never really completely worked, at least
not going as far back as NB 3.3 with the introduction of layerization
of system options, but it got much worse in NB 3.4, and hardly any
better in 3.5. Therefore marking a REGRESSION in 3.4.
Comment 5 Jesse Glick 2003-06-04 16:31:59 UTC
Created attachment 10589 [details]
NB 3.4.1 version of the module
Comment 6 Jesse Glick 2003-06-04 16:32:57 UTC
Created attachment 10590 [details]
NB 3.3.2 version of the module; note - Options link is broken, so to see Options-like view of option, unhide SFS in Filesystems Settings, then look under Default System -> Services
Comment 7 David Konecny 2003-06-04 16:48:27 UTC
Thanx for detailed testcase. That will help a lot. My first reaction
is: this probably never worked correctly and hopefully if new projects
are implemented soon we could kill this completely for next version so
maybe this is not worth to fix. But I would like to look at it to
learn more about the internals.

Tentatively marking as 4.0 milestone.
Comment 8 David Konecny 2003-06-05 16:02:01 UTC
Created attachment 10606 [details]
binary patch
Comment 9 David Konecny 2003-06-05 16:02:34 UTC
Created attachment 10607 [details]
source code patch
Comment 10 David Konecny 2003-06-05 16:27:06 UTC
Attached is binary and source code patch which I just finished. The
attached testcase worked fine on it. The binary patch must be put into
netbeans\modules\autoload\patches\org-netbeans-modules-settings
folder in the installation of NB. Should work for main trunk and NB35
because there was no change in trunk yet. Let me know if it works. It
is not final and patch might require some refactorings.

The problem is following:
InstanceDO created for .settings file has lookup created by
SerialDataConvertor. The SDC listens on underlaying fileobject and if
there is a change (for example during the project switch) it modifies
the lookup of the InstanceDO. More precisely it replaces
InstanceCookie with a new one. The SystemOption is created by
retrieving InstanceCookie from InstanceDO and by calling
createInstance() on it. So far everything is OK. The problem is that
once the SystemOption was created there is nobody who is listening on
the lookup changes of the InstanceDO! And because of that the new
InstanceCookie which was added into lookup by SerialDataConvertor is
never called. If Options dialog is shown then there is an InstanceNode
which listens on it and it somehow (I did not look into the details,
just saw it from stack trace) causes the recreation of the SystemOption.

The fix of this problem should be probably in some different place,
but at the moment I did it directly in the SerialDataConvertor. It is
very simple: if instance was already created from the InstanceCookie
and IC is being replaced with the new one then I simply force creation
of the new object (iff it is SystemOption subclass) what results in
needed recreation of SystemOption and because SO is singleton the rest
is straightforward.
Comment 11 David Konecny 2003-06-12 12:14:01 UTC
Fixed in trunk:
Checking in
settings/src/org/netbeans/modules/settings/convertors/SerialDataConv
ertor.java;
new revision: 1.21; previous revision: 1.20
Checking in src/org/netbeans/core/projects/SerialDataConvertor.java;
new revision: 1.22; previous revision: 1.21
Comment 12 David Konecny 2003-06-12 12:17:24 UTC
I was thinking about marking this SIMPLEFIX, but I'm not sure about
that. The problem is serious, the fix is simple and should not have
any sideeffects, but this problem is there for years (at least since
NB3.3) without being noticed.

Anyway, marking as SIMPLEFIX.
Comment 13 David Konecny 2003-07-28 15:21:50 UTC
There was NPE reported in issue 35086 caused by this fix.

Improved in:

Checking in src/org/netbeans/core/projects/SerialDataConvertor.java;
new revision: 1.23; previous revision: 1.22
Checking in
settings/src/org/netbeans/modules/settings/convertors/SerialDataConvertor.java;
new revision: 1.22; previous revision: 1.21
Comment 14 David Konecny 2003-08-06 10:37:08 UTC
*** Issue 35182 has been marked as a duplicate of this issue. ***
Comment 15 Lukas Hasik 2004-02-26 14:56:27 UTC
verifying, it looong time in code