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 16761 - Storing null to file attr on SFS saves serialized MultiFileObject.VoidValue
Summary: Storing null to file attr on SFS saves serialized MultiFileObject.VoidValue
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Filesystems (show other bugs)
Version: 3.x
Hardware: PC Linux
: P4 blocker (vote)
Assignee: Jaroslav Tulach
URL:
Keywords: T9Y
: 13279 (view as bug list)
Depends on: 199189
Blocks: 36154
  Show dependency tree
 
Reported: 2001-10-19 14:40 UTC by Jesse Glick
Modified: 2011-07-30 13:45 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Diff of the hack applied on commit-validation test (1.23 KB, patch)
2003-10-16 12:52 UTC, Peter Zavadsky
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2001-10-19 14:40:11 UTC
[dev oct 19] I hope I can explain this clearly.

Make yourself a new template in Options, e.g. some Java source or something,
marking it as a template. The .nbattrs file on disk correctly shows:

   <fileobject name="whatever">
      <attr name="template" boolvalue="true"/>
   </fileobject>

Fine. Now switch template off. In code, this means setting the attribute to
null. You get this:

      <attr name="template"
serialvalue="aced0005737200316f72672e6f70656e6964652e66696c6573797374656d732e4d756c746946696c654f626a65637424566f696456616c7565d9ec9c94d5fd3ca40c0000787077040000000178"/>

(probably a MFO.NullValue)

This is wrong. MFO.NV is supposed to be used to explicitly mark a value which
should be null, where otherwise some overriding layer in the MFS would make it
non-null. But there is no other layer in the MFS providing this file: we have
just created it in the user system/ folder.

So instead it should simply delete the <attr> element. This would cause the
value of 'template' to be null, as desired.
Comment 1 rmatous 2001-10-29 13:05:19 UTC
Definitely performance will be affected.
Comment 2 Jesse Glick 2001-10-29 18:32:57 UTC
It's probably not important enough to justify any performance loss. I
did not realize that was a factor (no longer know much about internals
of MultiFileObject attr merging....).
Comment 3 rmatous 2001-10-30 08:12:38 UTC
So, I decrease priority.
Comment 4 Jan Chalupa 2001-11-27 13:03:51 UTC
Target milestone -> 3.3.1.
Comment 5 rmatous 2002-01-10 13:39:06 UTC
*** Issue 13279 has been marked as a duplicate of this issue. ***
Comment 6 Marek Grummich 2002-07-22 11:25:35 UTC
Set target milestone to TBD
Comment 7 Marek Grummich 2002-07-22 11:27:59 UTC
Set target milestone to TBD
Comment 8 rmatous 2003-03-21 10:17:06 UTC
Target milestone was changed.
Comment 9 rmatous 2003-05-21 09:11:52 UTC
Added CC: dkonecny.
Comment 10 David Konecny 2003-05-21 15:12:08 UTC
I have similar problem. I'm implementing reverting in Registry API.
Here is my case:
* a folder has an attribute which is specified in module's layer. 
* user deleted the attribute on SystemFS. This results in creation
MFO.NullValue as Jesse mentioned.

Now when I want to revert this modification I thought that I could get
SESSION layer FS from Session manager and simply delete the attribute.
But this does not work. The Session layer FS is another MultiFS and
deletion of attribute results again in creation of MFO.NullValue.

But I think I can workaround my problem. Just wanted to recorded it here.
Comment 11 rmatous 2003-09-17 12:12:59 UTC
This issue causes, that method getAttributes lists also attributes,
that have null value and thus should be considered as deleted. This is
particularly strange if you get FileAttributeEvent, which notifies
you, that attriubute was deleted and method getAttributes list it.
Comment 12 Jesse Glick 2003-09-18 06:07:36 UTC
Should be obsoleted by Registry anyway, of course.
Comment 13 Peter Zavadsky 2003-10-16 12:51:37 UTC
This issue causes failure of validation test for new winsys. Hacking
the test by commit:

core/test/unit/../projects/ValidateLayerConstistencyTest.java 1.3.20.2

In case this issue is fixed, please remove that hack.
Comment 14 Peter Zavadsky 2003-10-16 12:52:24 UTC
Created attachment 11884 [details]
Diff of the hack applied on commit-validation test
Comment 15 Jesse Glick 2007-10-16 01:14:40 UTC
I found when reproducing issue #115343 that when a folder is reordered, OpenIDE-Folder-Order is written as (serialized)
null to $userdir/config/.nbattrs even though it was not set to begin with.

Checking in FolderOrder.java;
/shared/data/ccvs/repository/openide/loaders/src/org/openide/loaders/FolderOrder.java,v  <--  FolderOrder.java
new revision: 1.10; previous revision: 1.9
done
Comment 16 Antonin Nebuzelsky 2008-04-15 17:15:34 UTC
Reassigning to new module owner jskrivanek.
Comment 17 Jiri Skrivanek 2008-11-21 10:08:07 UTC
Performance may be affected by the fix.
Comment 18 Quality Engineering 2009-11-02 10:59:14 UTC
NetBeans.org Migration: changing resolution from LATER to WONTFIX
Comment 19 Jesse Glick 2010-11-18 18:38:28 UTC
Still broken. Created a new file on the SFS, and called setAttribute(..., null). .nbattrs then had:

<attr name="..." serialvalue="aced0005737200316f72672e6f70656e6964652e66696c6573797374656d732e4d756c746946696c654f626a65637424566f696456616c7565d9ec9c94d5fd3ca40c0000787077040000000178"/>

where that deserializes to MultiFileObject.VoidValue.

Surely fixable somehow. Even if it cannot be handled correctly by MultiFileSystem, at least XMLMapAttrs can handle this special case.
Comment 20 Quality Engineering 2010-11-21 06:08:40 UTC
Integrated into 'main-golden', will be available in build *201011210001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/18c6043dc69d
User: Jesse Glick <jglick@netbeans.org>
Log: Work around #16761 (null storage bug).
Comment 21 Jaroslav Tulach 2010-11-25 12:31:23 UTC
Valid? Can you write a unit test?
Comment 22 Jesse Glick 2010-11-29 19:32:23 UTC
(In reply to comment #21)
> Valid?

Yes.

> Can you write a unit test?

core-main #ce6e92f95dbc
Comment 23 Quality Engineering 2010-12-01 06:38:45 UTC
Integrated into 'main-golden', will be available in build *201012010001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ce6e92f95dbc
User: Jesse Glick <jglick@netbeans.org>
Log: Disabled test for #16761.
Comment 24 Jaroslav Tulach 2011-03-08 05:01:25 UTC
ergonomics#17e9dcddf9d2
Comment 25 Quality Engineering 2011-03-09 05:37:31 UTC
Integrated into 'main-golden', will be available in build *201103090000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/17e9dcddf9d2
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #16761: Don't store null, when previous value is also null
Comment 26 Quality Engineering 2011-03-12 09:42:11 UTC
Integrated into 'main-golden', will be available in build *201103120400* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/6984ab74084c
User: Jesse Glick <jglick@netbeans.org>
Log: Cleaner handling of repo persistence.
1. Use FileUtil.get/setOrder.
2. Assume fix of #16761.
Comment 27 Quality Engineering 2011-05-11 19:41:06 UTC
Integrated into 'main-golden', will be available in build *201105111436* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/7ca066d3d98d
User: Jesse Glick <jglick@netbeans.org>
Log: Removing old workaround probably obsolete as of #16761.
Comment 28 Quality Engineering 2011-06-01 13:21:20 UTC
Integrated into 'main-golden', will be available in build *201106010401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/5d20e4e7eace
User: Jesse Glick <jglick@netbeans.org>
Log: Removing workaround for #16761.
Comment 29 Jesse Glick 2011-06-06 17:18:11 UTC
Related bug still open: if there was a value set in the underlying FS, clearing it via MFS stores VoidValue rather than simply null on the underlying FS:

diff --git a/openide.filesystems/test/unit/src/org/openide/filesystems/VoidValueTest.java b/openide.filesystems/test/unit/src/org/openide/filesystems/VoidValueTest.java
--- a/openide.filesystems/test/unit/src/org/openide/filesystems/VoidValueTest.java
+++ b/openide.filesystems/test/unit/src/org/openide/filesystems/VoidValueTest.java
@@ -98,6 +98,9 @@
         assertEquals(Collections.emptyList(), Collections.list(baseFile.getAttributes()));
         assertEquals(Collections.emptyList(), Collections.list(derivedFile.getAttributes()));
         assertFalse(new File(getWorkDir(), ".nbattrs").isFile());
+        baseFile.setAttribute("real", "whatever");
+        derivedFile.setAttribute("real", null);
+        assertNull(baseFile.getAttribute("real"));
     }
 
 }
Comment 30 Jaroslav Tulach 2011-07-29 08:22:45 UTC
Moved into separate test, but...

# This patch file was generated by NetBeans IDE
# It uses platform neutral UTF-8 encoding and \n newlines.
--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -100,4 +100,17 @@
         assertFalse(new File(getWorkDir(), ".nbattrs").isFile());
     }
 
+    public void testVoidValue() throws Exception { 
+        clearWorkDir();
+        LocalFileSystem local = new LocalFileSystem();
+        local.setRootDirectory(getWorkDir());
+        FileObject baseFile = local.getRoot().createData("file");
+        MultiFileSystem mfs = new MultiFileSystem(new FileSystem[] {local});
+        FileObject derivedFile = mfs.findResource("file");
+        baseFile.setAttribute("real", "whatever");
+        derivedFile.setAttribute("real", null);
+        assertNull("Derived attribute nullified", derivedFile.getAttribute("real"));
+        assertNull("Underlaying attribute is not void", baseFile.getAttribute("real"));
 }
+
+}
Comment 31 Jaroslav Tulach 2011-07-29 09:51:30 UTC
ergonomics#9506f0a1f9ee
Comment 32 Jaroslav Tulach 2011-07-29 09:51:58 UTC
Last fix goes only to 7.1
Comment 33 Quality Engineering 2011-07-30 13:45:42 UTC
Integrated into 'main-golden', will be available in build *201107300600* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/9506f0a1f9ee
User: Jaroslav Tulach <jtulach@netbeans.org>
Log: #16761: Storing null to file attr on SFS saves serialized MultiFileObject.VoidValue
Don't use VoidValue when not necessary