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 194656 - Old data returned on DDProvider.getDDRoot(FileObject)
Summary: Old data returned on DDProvider.getDDRoot(FileObject)
Status: RESOLVED WONTFIX
Alias: None
Product: javaee
Classification: Unclassified
Component: DD Editor (show other bugs)
Version: 7.0
Hardware: PC Linux
: P3 normal (vote)
Assignee: issues@javaee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-01-24 13:21 UTC by Petr Hejl
Modified: 2015-09-17 13:10 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
test case (8.79 KB, patch)
2011-01-24 13:22 UTC, Petr Hejl
Details | Diff
updated test (8.79 KB, patch)
2011-01-24 15:15 UTC, Petr Hejl
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Petr Hejl 2011-01-24 13:21:42 UTC
I'm not sure how is caching mechanism supposed to work, however it returns (or at least it may return) old model if the underlying data has been changed before the second call.

See attached test case.
Comment 1 Petr Hejl 2011-01-24 13:22:13 UTC
Created attachment 105304 [details]
test case
Comment 2 Petr Jiricka 2011-01-24 14:30:56 UTC
In the test, application2.xml is not used anywhere. Did not you mean to write this?

File updated = new File(dataDir, "application/application2.xml");
Comment 3 Petr Hejl 2011-01-24 15:15:34 UTC
Created attachment 105307 [details]
updated test

Still fails on assertEquals(2, app.getModule().length);
Comment 4 Petr Jiricka 2011-01-26 13:38:58 UTC
Hi Denis, could you please also take a look at this one? Thanks.
Comment 5 Denis Anisimov 2011-01-26 14:13:36 UTC
Not yet investigated it deeply but at first glance this is not a bug.
I don't know exactly how the model which is used for Application is written
but f.e. XAM/XDM based models require explicit "sync" for synchronization with 
underlying content.
Such "sync" could be result of Document listener (reaction on some editor event).

I'm not sure that FileUtil.refreshFor is enough for model synchronization .

I need to investigate this deeply.
Comment 6 Denis Anisimov 2011-01-26 14:34:22 UTC
Hm , I see from implementation of DDProvider that it really should update 
model on File change event.

But described behavior is not unexpected :
real files refresh is performed in the separate thread  and 
file change event could arrive after model call is done in the main thread.
This is exactly what happens :
the second call app = DDProvider.getDefault().getDDRoot(workingObject);
is first ( in the time frame ) and model update on file event change is the 
second.

The question is : do you really need updated model right after File change ?
From the user perspective I don't see the real need in such behavior.
It could be a problem only for writing tests .
But it could be solved via own FileChangeListener implementation .

To fix the described problem explicit method "sync" could be added into the 
application api.
Comment 7 Petr Hejl 2011-01-28 12:02:03 UTC
The resolution WORKSFORME does not seem to be ok. Either it is INVALID or WONTFIX. Obviously the test case does not work.

BTW There is real need to see an updated model, especially when you do things like deployment. The delay between the file change and the listener notification may be really long.

At least you may document in the API that it works this way. Otherwise sooner or later somebody else will hit this again.
Comment 8 Denis Anisimov 2011-01-28 15:06:55 UTC
>The resolution WORKSFORME does not seem to be ok. Either it is INVALID or
>WONTFIX. Obviously the test case does not work.
There was a resolution INCOMPLETE. Without your reaction. 
Not working test doesn't mean the problem with functionality for which test is 
written . It could mean incorrectly written test.

I have suggested to you the solution.
It does work for me. So I mark this issue respectively.

>BTW There is real need to see an updated model, especially when you do things
>like deployment. The delay between the file change and the listener
>notification may be really long.
So WHY you didn't respond with this notion when I set the resolution as INCOMLETE?

>At least you may document in the API that it works this way. Otherwise sooner
>or later somebody else will hit this again.
I'm not an owner or responsible person for this functionality .
Petr assigned this issue to me for evaluation and fix if it possible.
You are able to add javadoc in this API exactly as me.

I've suggested the solution for immediate update of the model : introduce method
"sync". 
But the module under the subject is open API and the procedure of change is too 
complected.
It could be done after 7.0 release.
Comment 9 Petr Hejl 2011-01-28 17:09:21 UTC
Hi Denis,
I just wrote what I thought should be done, nothing more.

P.

Javadoc updated: web-main d6309af212e5.
Comment 10 Quality Engineering 2011-02-01 05:57:30 UTC
Integrated into 'main-golden', will be available in build *201102010000* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/d6309af212e5
User: Petr Hejl <phejl@netbeans.org>
Log: #194656 Old data returned on DDProvider.getDDRoot(FileObject)
Comment 11 Martin Balin 2015-09-17 13:10:30 UTC
Report from old NetBeans version. Due to code changes since it was reported likely not reproducible now. Feel free to reopen if happens in 8.0.2 or 8.1.