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 34404

Summary: Double notification from AbstractFileObject
Product: platform Reporter: David Strupl <dstrupl>
Component: FilesystemsAssignee: rmatous <rmatous>
Status: VERIFIED WONTFIX    
Severity: blocker Keywords: SIMPLEFIX
Priority: P4    
Version: 3.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:
Bug Depends on:    
Bug Blocks: 32247    
Attachments: AFO diff
Use rather the this one for your test

Description David Strupl 2003-06-16 13:04:56 UTC
Hi,

I have tried to make my filesystem (actually
Jesse's WritableXMLFileSystem
adapted - don't worry I will post the changes)
pass all the junit tests
from
openide/test/unit/src/org/openide/filesystems/.
BTW the
infrastructure for the tests is quite easy to use
and simply cool.

By modifying my FS I was not able to make all the
tests pass. There were
errors due to double notifications of change while
doing move operation
(see bellow for report). The only way I was able
to pass the tests was
following change in AbstractFileObject.java (from
release35 branch):

$cvs diff AbstractFileObject.java
Index: AbstractFileObject.java
===================================================================
RCS file:
/cvs/openide/src/org/openide/filesystems/AbstractFileObject.java,v
retrieving revision 1.83.2.3
diff -r1.83.2.3 AbstractFileObject.java
636c636
<                         parent.refresh (null, oldN);
---
> //                        parent.refresh (null,
oldN);

With this change all the local and jar file system
tests still pass so the
change can be quite innocent - is there someone
who knows why the line is
there? Is it some CVS FS magic (BTW is there a way
how can I run the nice
FS tests for CVS fs?)? The notification of
listeners is on lines 652-658
so why is there another one on line 636?

Any help greatly appreciated,

David Strupl
==============================================================
Test report when the change in AbstractFileObject
is not in place

...............................org.openide.filesystems.FileEvent[source=testFolder0][file=testFolder0/test.txt0,time=1055726720715,expected=fa
lse,fs=[foo.WritableXMLFileSystem@13d28e3]]
========================java.lang.Exception
        at
org.openide.filesystems.FileEvent.<init>(FileEvent.java:59)
        at
org.openide.filesystems.FileEvent.<init>(FileEvent.java:83)
        at
org.openide.filesystems.AbstractFolder.fileDeleted0(AbstractFolder.java:421)
        at
org.openide.filesystems.AbstractFolder.refreshFolder(AbstractFolder.java:772)
        at
org.openide.filesystems.AbstractFolder.refresh(AbstractFolder.java:795)
        at
org.openide.filesystems.AbstractFileObject.refresh(AbstractFileObject.java:708)
        at
org.openide.filesystems.AbstractFolder.refresh(AbstractFolder.java:566)
        at
org.openide.filesystems.AbstractFolder.refresh(AbstractFolder.java:545)
        at
org.openide.filesystems.AbstractFileObject.move(AbstractFileObject.java:636)
        at
org.openide.filesystems.FileObjectTestHid.testMove1(FileObjectTestHid.java:183)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at
java.lang.reflect.Method.invoke(Method.java:324)
        at
junit.framework.TestCase.runTest(TestCase.java:154)
        at
junit.framework.TestCase.runBare(TestCase.java:127)
        at
junit.framework.TestResult$1.protect(TestResult.java:106)
        at
junit.framework.TestResult.runProtected(TestResult.java:124)
        at
junit.framework.TestResult.run(TestResult.java:109)
        at
junit.framework.TestCase.run(TestCase.java:118)
        at
org.netbeans.junit.NbTestCase.run(NbTestCase.java:76)
        at
org.openide.filesystems.MultiThreadedTestCaseHid.run(MultiThreadedTestCaseHid.java:54)
        at
junit.framework.TestSuite.runTest(TestSuite.java:208)
        at
junit.framework.TestSuite.run(TestSuite.java:203)
        at
junit.framework.TestSuite.runTest(TestSuite.java:208)
        at
junit.framework.TestSuite.run(TestSuite.java:203)
        at
junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at
org.netbeans.junit.NbTestSetup$1.protect(NbTestSetup.java:33)
        at
junit.framework.TestResult.runProtected(TestResult.java:124)
        at
org.netbeans.junit.NbTestSetup.run(NbTestSetup.java:37)
        at
junit.textui.TestRunner.doRun(TestRunner.java:116)
        at
junit.textui.TestRunner.doRun(TestRunner.java:109)
        at
junit.textui.TestRunner.run(TestRunner.java:72)
        at
foo.WritableXMLFileSystemTest2.main(WritableXMLFileSystemTest2.java:38)
org.openide.filesystems.FileEvent[source=testFolder0][file=testFolder0/test.txt0,time=1055726720715,expected=false,fs=[foo.WritableXMLFileSyst
em@13d28e3]]
========================java.lang.Exception
        at
org.openide.filesystems.FileEvent.<init>(FileEvent.java:59)
        at
org.openide.filesystems.FileEvent.<init>(FileEvent.java:83)
        at
org.openide.filesystems.AbstractFolder.fileDeleted0(AbstractFolder.java:421)
        at
org.openide.filesystems.AbstractFileObject.move(AbstractFileObject.java:653)
        at
org.openide.filesystems.FileObjectTestHid.testMove1(FileObjectTestHid.java:183)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at
java.lang.reflect.Method.invoke(Method.java:324)
        at
junit.framework.TestCase.runTest(TestCase.java:154)
        at
junit.framework.TestCase.runBare(TestCase.java:127)
        at
junit.framework.TestResult$1.protect(TestResult.java:106)
        at
junit.framework.TestResult.runProtected(TestResult.java:124)
        at
junit.framework.TestResult.run(TestResult.java:109)
        at
junit.framework.TestCase.run(TestCase.java:118)
        at
org.netbeans.junit.NbTestCase.run(NbTestCase.java:76)
        at
org.openide.filesystems.MultiThreadedTestCaseHid.run(MultiThreadedTestCaseHid.java:54)
        at
junit.framework.TestSuite.runTest(TestSuite.java:208)
        at
junit.framework.TestSuite.run(TestSuite.java:203)
        at
junit.framework.TestSuite.runTest(TestSuite.java:208)
        at
junit.framework.TestSuite.run(TestSuite.java:203)
        at
junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at
org.netbeans.junit.NbTestSetup$1.protect(NbTestSetup.java:33)
        at
junit.framework.TestResult.runProtected(TestResult.java:124)
        at
org.netbeans.junit.NbTestSetup.run(NbTestSetup.java:37)
        at
junit.textui.TestRunner.doRun(TestRunner.java:116)
        at
junit.textui.TestRunner.doRun(TestRunner.java:109)
        at
junit.textui.TestRunner.run(TestRunner.java:72)
        at
foo.WritableXMLFileSystemTest2.main(WritableXMLFileSystemTest2.java:38)
F.org.openide.filesystems.FileEvent[source=testFolder0][file=testFolder0/test.txt0,time=1055726720928,expected=false,fs=[foo.WritableXMLFileSy
stem@2acc65]]
========================java.lang.Exception
        at
org.openide.filesystems.FileEvent.<init>(FileEvent.java:59)
        at
org.openide.filesystems.FileEvent.<init>(FileEvent.java:83)
        at
org.openide.filesystems.AbstractFolder.fileDeleted0(AbstractFolder.java:421)
        at
org.openide.filesystems.AbstractFolder.refreshFolder(AbstractFolder.java:772)
        at
org.openide.filesystems.AbstractFolder.refresh(AbstractFolder.java:795)
        at
org.openide.filesystems.AbstractFileObject.refresh(AbstractFileObject.java:708)
        at
org.openide.filesystems.AbstractFolder.refresh(AbstractFolder.java:566)
        at
org.openide.filesystems.AbstractFolder.refresh(AbstractFolder.java:545)
        at
org.openide.filesystems.AbstractFileObject.move(AbstractFileObject.java:636)
        at
org.openide.filesystems.FileObjectTestHid.testMove1_Fs(FileObjectTestHid.java:221)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at
java.lang.reflect.Method.invoke(Method.java:324)
        at
junit.framework.TestCase.runTest(TestCase.java:154)
        at
junit.framework.TestCase.runBare(TestCase.java:127)
        at
junit.framework.TestResult$1.protect(TestResult.java:106)
        at
junit.framework.TestResult.runProtected(TestResult.java:124)
        at
junit.framework.TestResult.run(TestResult.java:109)
        at
junit.framework.TestCase.run(TestCase.java:118)
        at
org.netbeans.junit.NbTestCase.run(NbTestCase.java:76)
        at
org.openide.filesystems.MultiThreadedTestCaseHid.run(MultiThreadedTestCaseHid.java:54)
        at
junit.framework.TestSuite.runTest(TestSuite.java:208)
        at
junit.framework.TestSuite.run(TestSuite.java:203)
        at
junit.framework.TestSuite.runTest(TestSuite.java:208)
        at
junit.framework.TestSuite.run(TestSuite.java:203)
        at
junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at
org.netbeans.junit.NbTestSetup$1.protect(NbTestSetup.java:33)
        at
junit.framework.TestResult.runProtected(TestResult.java:124)
        at
org.netbeans.junit.NbTestSetup.run(NbTestSetup.java:37)
        at
junit.textui.TestRunner.doRun(TestRunner.java:116)
        at
junit.textui.TestRunner.doRun(TestRunner.java:109)
        at
junit.textui.TestRunner.run(TestRunner.java:72)
        at
foo.WritableXMLFileSystemTest2.main(WritableXMLFileSystemTest2.java:38)
org.openide.filesystems.FileEvent[source=testFolder0][file=testFolder0/test.txt0,time=1055726720928,expected=false,fs=[foo.WritableXMLFileSyst
em@2acc65]]
========================java.lang.Exception
        at
org.openide.filesystems.FileEvent.<init>(FileEvent.java:59)
        at
org.openide.filesystems.FileEvent.<init>(FileEvent.java:83)
        at
org.openide.filesystems.AbstractFolder.fileDeleted0(AbstractFolder.java:421)
        at
org.openide.filesystems.AbstractFileObject.move(AbstractFileObject.java:653)
        at
org.openide.filesystems.FileObjectTestHid.testMove1_Fs(FileObjectTestHid.java:221)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at
java.lang.reflect.Method.invoke(Method.java:324)
        at
junit.framework.TestCase.runTest(TestCase.java:154)
        at
junit.framework.TestCase.runBare(TestCase.java:127)
        at
junit.framework.TestResult$1.protect(TestResult.java:106)
        at
junit.framework.TestResult.runProtected(TestResult.java:124)
        at
junit.framework.TestResult.run(TestResult.java:109)
        at
junit.framework.TestCase.run(TestCase.java:118)
        at
org.netbeans.junit.NbTestCase.run(NbTestCase.java:76)
        at
org.openide.filesystems.MultiThreadedTestCaseHid.run(MultiThreadedTestCaseHid.java:54)
        at
junit.framework.TestSuite.runTest(TestSuite.java:208)
        at
junit.framework.TestSuite.run(TestSuite.java:203)
        at
junit.framework.TestSuite.runTest(TestSuite.java:208)
        at
junit.framework.TestSuite.run(TestSuite.java:203)
        at
junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at
org.netbeans.junit.NbTestSetup$1.protect(NbTestSetup.java:33)
        at
junit.framework.TestResult.runProtected(TestResult.java:124)
        at
org.netbeans.junit.NbTestSetup.run(NbTestSetup.java:37)
        at
junit.textui.TestRunner.doRun(TestRunner.java:116)
        at
junit.textui.TestRunner.doRun(TestRunner.java:109)
        at
junit.textui.TestRunner.run(TestRunner.java:72)
        at
foo.WritableXMLFileSystemTest2.main(WritableXMLFileSystemTest2.java:38)
F..
......
.........................................
.............
Time: 8,9
There were 2 failures:
1)
testMove1(org.openide.filesystems.FileObjectTestHid)junit.framework.AssertionFailedError:
parent should fire fileDeleted Fired : 2 ,but
expected: 1
[foo.WritableXMLFileSystemTest2]
        at
org.openide.filesystems.TestBaseHid.fsAssert(TestBaseHid.java:89)
        at
org.openide.filesystems.TestBaseHid.fileEventAssert(TestBaseHid.java:128)
        at
org.openide.filesystems.TestBaseHid.fileDeletedAssert(TestBaseHid.java:105)
        at
org.openide.filesystems.FileObjectTestHid.testMove1(FileObjectTestHid.java:198)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at
org.netbeans.junit.NbTestCase.run(NbTestCase.java:76)
        at
org.openide.filesystems.MultiThreadedTestCaseHid.run(MultiThreadedTestCaseHid.java:54)
        at
junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at
org.netbeans.junit.NbTestSetup$1.protect(NbTestSetup.java:33)
        at
org.netbeans.junit.NbTestSetup.run(NbTestSetup.java:37)
        at
foo.WritableXMLFileSystemTest2.main(WritableXMLFileSystemTest2.java:38)
2)
testMove1_Fs(org.openide.filesystems.FileObjectTestHid)junit.framework.AssertionFailedError:
parent should fire fileDeleted Fired : 2 ,but
expected: 1
[foo.WritableXMLFileSystemTest2]
        at
org.openide.filesystems.TestBaseHid.fsAssert(TestBaseHid.java:89)
        at
org.openide.filesystems.TestBaseHid.fileEventAssert(TestBaseHid.java:128)
        at
org.openide.filesystems.TestBaseHid.fileDeletedAssert(TestBaseHid.java:105)
        at
org.openide.filesystems.FileObjectTestHid.testMove1_Fs(FileObjectTestHid.java:236)
        at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at
org.netbeans.junit.NbTestCase.run(NbTestCase.java:76)
        at
org.openide.filesystems.MultiThreadedTestCaseHid.run(MultiThreadedTestCaseHid.java:54)
        at
junit.extensions.TestDecorator.basicRun(TestDecorator.java:22)
        at
org.netbeans.junit.NbTestSetup$1.protect(NbTestSetup.java:33)
        at
org.netbeans.junit.NbTestSetup.run(NbTestSetup.java:37)
        at
foo.WritableXMLFileSystemTest2.main(WritableXMLFileSystemTest2.java:38)
FAILURES!!!
Tests run: 95,  Failures: 2,  Errors: 0
Comment 1 David Strupl 2003-06-19 14:59:49 UTC
Fixed on branch platform_32247.
Comment 2 rmatous 2003-07-04 15:32:47 UTC
Target milestone: 4.0.
Comment 3 David Strupl 2004-02-16 17:35:43 UTC
Radek, are you going to commit this? I even don't remember exactly how
long it is sitting here but I assume you understand the code. And if
the change is ok, please consider applying it. If it is nonsense
please mark as wontfix. It is in the same state from 19.6.2003!
Comment 4 rmatous 2004-02-17 18:11:05 UTC
Its one of less priority issues in a queue for target milestone 3.6. 
I naturally plan  to fix it because it is relatively easy, safe and
harmless.  

Comment 5 rmatous 2004-02-26 09:39:40 UTC
I have no NbTestSetup subclass to test it with. But refresh (String
added, String removed) shouldn't fire events neither for "added"
resource nor for "removed". Definitely there is wrong call of this
method. Please try parent.refresh (null, this.name) instead of 
parent.refresh (null, oldN). If your tests are OK I'll commit it
instantly because there isn't time enough.
Comment 6 David Strupl 2004-02-26 11:53:06 UTC
Hi,

with the original code I have two tests failing

junit.framework.AssertionFailedError: parent should fire
fileDataCreated Fired : 2 ,but expected: 1
[org.netbeans.modules.zeroadmin.XMLBufferFileSystemTest]
	at junit.framework.Assert.fail(Assert.java:51)
	at junit.framework.Assert.assertTrue(Assert.java:38)
	at org.openide.filesystems.TestBaseHid.fsAssert(TestBaseHid.java:89)
	at
org.openide.filesystems.TestBaseHid.fileEventAssert(TestBaseHid.java:117)
	at
org.openide.filesystems.TestBaseHid.fileDataCreatedAssert(TestBaseHid.java:97)
	at
org.openide.filesystems.FileObjectTestHid.testMove1(FileObjectTestHid.java:199)


junit.framework.AssertionFailedError: parent should fire fileDeleted
Fired : 2 ,but expected: 1
[org.netbeans.modules.zeroadmin.XMLBufferFileSystemTest]
	at junit.framework.Assert.fail(Assert.java:51)
	at junit.framework.Assert.assertTrue(Assert.java:38)
	at org.openide.filesystems.TestBaseHid.fsAssert(TestBaseHid.java:89)
	at
org.openide.filesystems.TestBaseHid.fileEventAssert(TestBaseHid.java:117)
	at
org.openide.filesystems.TestBaseHid.fileDeletedAssert(TestBaseHid.java:105)
	at
org.openide.filesystems.FileObjectTestHid.testMove1_Fs(FileObjectTestHid.java:236)

With your proposed change only the second one is ok. Your change
leaves still one test failing for me. If I completely remove the line
in question all the tests pass.

But please note that I have been testing this on NB3.5 since I don't
have the xtest build scripts updated for 3.6 yet. I hope that there
were not some changes in AbstractFileObject that could affect this
between 3.5 and 3.6.
Comment 7 rmatous 2004-02-26 12:45:23 UTC
Its a pity, that you don't mention how testMove1 failed. But I assume
that now fails FileObjectTestHid.testMove1.fileDataCreatedAssert
instead of fileDeletedAssert. If I'm right then parent.refresh (n,
this.name) should be OK. If so then please let me know and I fix it.
            
            
Comment 8 David Strupl 2004-02-26 12:59:53 UTC
Sorry I messed up the failures. With your change this happened:
testMove1:

junit.framework.AssertionFailedError: parent should fire
fileDataCreated Fired : 2 ,but expected: 1
[org.netbeans.modules.zeroadmin.XMLBufferFileSystemTest]
	at junit.framework.Assert.fail(Assert.java:51)
	at junit.framework.Assert.assertTrue(Assert.java:38)
	at org.openide.filesystems.TestBaseHid.fsAssert(TestBaseHid.java:89)
	at
org.openide.filesystems.TestBaseHid.fileEventAssert(TestBaseHid.java:117)
	at
org.openide.filesystems.TestBaseHid.fileDataCreatedAssert(TestBaseHid.java:97)
	at
org.openide.filesystems.FileObjectTestHid.testMove1(FileObjectTestHid.java:199)

What do you mean that it is ok? Is this test expected to fail this way?
Comment 9 rmatous 2004-02-26 13:06:05 UTC
Naturally it isn't. But if you changed parent.refresh (null,
this.name)  into parent.refresh (n, this.name) then the test could
pass, which I think could be OK.
Comment 10 David Strupl 2004-02-26 13:18:04 UTC
No. After I did your change the two move tests end up with error:

java.io.FileNotFoundException: testFolder0/test.txt0
	at
org.netbeans.modules.zeroadmin.XMLBufferFileSystem.getContentsOf(XMLBufferFileSystem.java:265)
	at
org.netbeans.modules.zeroadmin.XMLBufferFileSystem.inputStream(XMLBufferFileSystem.java:323)
	at
org.openide.filesystems.AbstractFileObject.getInputStream(AbstractFileObject.java:164)
	at
org.openide.filesystems.FileObjectTestHid.readStr(FileObjectTestHid.java:1586)
	at
org.openide.filesystems.FileObjectTestHid.testMove1_Fs(FileObjectTestHid.java:229)

I don't know whether the error is due to a problem in my filesystem or
in the tests or ...?
Comment 11 rmatous 2004-02-26 13:57:23 UTC
Created attachment 13669 [details]
AFO diff
Comment 12 rmatous 2004-02-26 14:05:21 UTC
Created attachment 13670 [details]
Use rather the this one for your test
Comment 13 rmatous 2004-02-26 14:06:27 UTC
Its not easy for me because I have not no testSuit for FS with
implemented Transfer. So, attached patch and I hope this is last
iteration. If not, then I give it up (at least for today). 
Comment 14 David Strupl 2004-02-26 14:27:01 UTC
Sorry I give it up (at least for today). I am not able to use this
version in NB 3.5 where I have the tests setup. I will try to update
the configs for my tests to NB 3.6. I will let you know then how does
your latest patch perform. But I have to go out with little Kata now ;-)
Comment 15 rmatous 2004-04-01 12:50:42 UTC
Please test the last patch. 
Comment 16 rmatous 2004-06-30 16:25:38 UTC
Nobody interested to test the last patch anymore.
Comment 17 David Strupl 2004-06-30 16:38:57 UTC
Hi,
sorry about that. I have simply removed the failing tests from my test
config long time ago. I had to deliver the platform with the test and
did not have the time to play with the tests ;-(
And currently we did not moved to trunk yet - I still work with my
copy of release 3.6. After I will have to start worry about trunk it
will be late for any fix again. fck it.
I suggest even closing this bug - I will enter a new one if after
moving to the trunk (4.0) some test will still fail for me. Sorry for
bothering you with this.
Best, David
Comment 18 Marian Mirilovic 2005-07-12 10:03:19 UTC
closed