Bug 357425 - DeltaProcessor misses state changes in archive files
Summary: DeltaProcessor misses state changes in archive files
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.8   Edit
Hardware: Other Linux
: P3 major with 1 vote (vote)
Target Milestone: 3.8 M3   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-09-12 18:03 EDT by Terry Parker CLA
Modified: 2012-05-28 05:52 EDT (History)
5 users (show)

See Also:
jarthana: review+


Attachments
Patch to DeltaProcessor.java (2.35 KB, patch)
2011-09-12 18:06 EDT, Terry Parker CLA
no flags Details | Diff
Add a ResetInvalidArchivesCache() function (2.00 KB, patch)
2011-09-12 18:21 EDT, Terry Parker CLA
no flags Details | Diff
Patch to fix the DeltaProcessor regeression and fix validateClasspathEntry(), with tests (9.25 KB, patch)
2011-10-10 12:54 EDT, Terry Parker CLA
no flags Details | Diff
Update to name the test jar files uniquely (8.97 KB, patch)
2011-10-14 12:02 EDT, Terry Parker CLA
jarthana: iplog+
Details | Diff
Patch with copyrights (9.94 KB, patch)
2011-10-19 07:38 EDT, Jay Arthanareeswaran CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Terry Parker CLA 2011-09-12 18:03:32 EDT
Build Identifier: I20110613-1736

The recent performance patch for the DeltaProcessor code resets the resolved classpath _only_ if it encounters a jar that contains chained jars in the resource delta.  This can miss two types of state change:

1) An archive that had chained jars is updated to contain no chained jars.  In this case the chained jars should get removed from the resolved classpath, if they are not pulled in by other jars.
2) setRawClasspath() is called with library jars that do not yet exist, so they are added to the invalid archive cache.  The missing jars subsequently get built, triggering the delta processor code.  Since the invalid archive cache only gets cleared when removing per-project info or when resetting the resolved classpath, the newly appearing jars remain in the invalid archive list and any classes within them remain unresolved.

For #1, to determine if a previously chained jar entry should be removed from the resolved classpath you need to either keep a reference count for each jar on the classpath, or just reset the resolved classpath and recalculate it.  Resetting the resolved classpath once per delta processor invocation doesn't appear to be a performance problem and is the simplest solution, so I will attach an initial patch that does that.

For #2 it seems like ClasspathEntry.validateClasspathEntry() should always clear the invalid archive list, but JavaModelManager.resetClasspathListCache() resets both that list and the non-chaining jars list, so attach a second patch that adds a new JavaModelManager.resetInvalidArchiveListCache() function and calls it in the beginning of ClasspathEntry.validateClasspathEntry().

Strictly speaking, patch #1 will fix both issues when dealing with invocations of the delta processor code, but not resetting the invalid archive list from Classpath.validateClasspathEntry() seems like a potential bug, given that that function attempts to update that state.

Also, I'd be happy to add a regression test for this issue if you point me at the appropriate place to add it.


Reproducible: Always

Steps to Reproduce:
1. Call setRawClasspath() with a library archive jar that doesn't exist
2. Validate that class files contained in the missing jar cause compilation erros/missing imports
3. Copy the missing jar into place, and refresh the project to pick it up
4. After the delta processor code executes, the new jar should resolve the missing classes, but it doesn't because the jar still exists in the invalid archive cache
Comment 1 Terry Parker CLA 2011-09-12 18:06:59 EDT
Created attachment 203194 [details]
Patch to DeltaProcessor.java

Always reset the resolved classpath on any change to an archive jar, not just when it contains a chained jar.
Comment 2 Terry Parker CLA 2011-09-12 18:21:01 EDT
Created attachment 203195 [details]
Add a ResetInvalidArchivesCache() function

Add a ResetInvalidArchivesCache() function and invoke it from ClasspathEntry.validateClasspathEntry()
Comment 3 Olivier Thomann CLA 2011-09-12 19:40:45 EDT
Jay, please follow up.
Comment 4 Jay Arthanareeswaran CLA 2011-09-16 01:53:08 EDT
(In reply to comment #0)
> Also, I'd be happy to add a regression test for this issue if you point me at
> the appropriate place to add it.
> 

The tests usually go to JavaElementDeltaTests or ClasspathTests, which you can find in the project org.eclipse.jdt.core.tests.model.

Olivier, this is indeed a regression from the bug 354332. But I think we could still keep the fixes we made already. Perhaps, should we reopen the bug 354332 and make it depend on this one?
Comment 5 Olivier Thomann CLA 2011-09-16 07:21:08 EDT
(In reply to comment #4)
> Olivier, this is indeed a regression from the bug 354332. But I think we could
> still keep the fixes we made already. Perhaps, should we reopen the bug 354332
> and make it depend on this one?
Yes, bug 354332 should be reopened to add the dependency on this one. If you think we should keep the fix in, then close it after this is done and work on a fix for this one.
Now do you think we should request a rebuild for M2 or we can have M2 with this issue in ?
Comment 6 Jay Arthanareeswaran CLA 2011-09-16 07:36:06 EDT
(In reply to comment #5)
> Now do you think we should request a rebuild for M2 or we can have M2 with this
> issue in ?

Considering that what is failing is not a common use case and that we have workaround, I don't think we need an M2 rebuild.
Comment 7 Olivier Thomann CLA 2011-10-04 10:40:14 EDT
This should be fixed before M3.
Comment 8 Jay Arthanareeswaran CLA 2011-10-05 11:57:59 EDT
(In reply to comment #0)
> Also, I'd be happy to add a regression test for this issue if you point me at
> the appropriate place to add it.

Any luck with the test? The patch looks good and it would be nice to have a regression test.
Comment 9 Terry Parker CLA 2011-10-05 19:19:16 EDT
I have just dug my way out from under my end-of-quarter tasks.  I'll take a look at adding tests tomorrow.
Comment 10 Terry Parker CLA 2011-10-10 12:54:28 EDT
Created attachment 204894 [details]
Patch to fix the DeltaProcessor regeression and fix validateClasspathEntry(), with tests
Comment 11 Jay Arthanareeswaran CLA 2011-10-12 06:33:19 EDT
(In reply to comment #10)
> Created attachment 204894 [details]
> Patch to fix the DeltaProcessor regeression and fix validateClasspathEntry(),
> with tests

Patch looks good and thanks. But one of the new tests is failing when the entire ClasspathTests is run. On debug I found that the delta processor sees the lib2.jar as already existing. I would suggest we use bug specific names in the test, such as Bug357425, lib357425_a.jar, lib357425_b.jar etc. to make the tests pass. I could do this, but I can't alter the patch.
Comment 12 Terry Parker CLA 2011-10-14 12:02:41 EDT
Created attachment 205212 [details]
Update to name the test jar files uniquely

I renamed that test as well to testBug357425() and moved it to the bottom of the file.
Comment 13 Srikanth Sankaran CLA 2011-10-18 15:42:01 EDT
(In reply to comment #12)
> Created attachment 205212 [details]
> Update to name the test jar files uniquely
> 
> I renamed that test as well to testBug357425() and moved it to the bottom of
> the file.

This patch passes all the tests. Jay, is anything else pending for this
bug ? If not can you close it ? Please remember to set the iplog and review
flags appropriately and make sure the copy right mentions the contribution.
Comment 14 Jay Arthanareeswaran CLA 2011-10-19 00:53:20 EDT
(In reply to comment #13)
> This patch passes all the tests. Jay, is anything else pending for this
> bug ? If not can you close it ? Please remember to set the iplog and review
> flags appropriately and make sure the copy right mentions the contribution.

Thanks, Srikanth. I will release the fix soon.
Comment 15 Jay Arthanareeswaran CLA 2011-10-19 07:38:26 EDT
Created attachment 205507 [details]
Patch with copyrights

Git patch, same as last one, but with updated copyright information.
Comment 16 Jay Arthanareeswaran CLA 2011-10-19 08:02:29 EDT
Released in HEAD for 3.8 M3 with commit 30fef0e89bd163d63b2dda342f5f4be753476e00
Terry, once again, thanks for the contribution.
Comment 17 Stephan Herrmann CLA 2011-10-25 09:18:38 EDT
I filed bug 361922 for possible improvements on the test coverage side.
Comment 18 Stephan Herrmann CLA 2011-10-25 09:20:04 EDT
Verified for 3.8 M3 using build N20111022-2000
Comment 19 Jay Arthanareeswaran CLA 2012-03-30 02:26:10 EDT
*** Bug 375249 has been marked as a duplicate of this bug. ***
Comment 20 Attila Csipak CLA 2012-05-24 10:34:52 EDT
(In reply to comment #6)
> (In reply to comment #5)
> > Now do you think we should request a rebuild for M2 or we can have M2 with this
> > issue in ?
> 
> Considering that what is failing is not a common use case and that we have
> workaround, I don't think we need an M2 rebuild.

Jay,

1. Any chance to backport the fix to version 3.7? (This bug is related to 3.8.2, but the bug still appears in 3.7.2, see Bug 375249, which you marked as duplicate.)

2. You mentioned a workaround, but I couldn't quite make out what you meant. Could you please elaborate on the topic? (The workarounds I desrcribed in Bug 375249 are nor stable nor close to comfortable.)

Thanks for the reply!
Comment 21 Jay Arthanareeswaran CLA 2012-05-28 01:45:46 EDT
(In reply to comment #20)
> 1. Any chance to backport the fix to version 3.7? (This bug is related to
> 3.8.2, but the bug still appears in 3.7.2, see Bug 375249, which you marked as
> duplicate.)

For reasons Satyam mentioned in bug 375249, comment #12, bug 375249 is probably not a duplicate of this one. Could you confirm if any of the 3.8 versions addresses your concern?

> 2. You mentioned a workaround, but I couldn't quite make out what you meant.
> Could you please elaborate on the topic? (The workarounds I desrcribed in Bug
> 375249 are nor stable nor close to comfortable.)

The workaround is same as the one you mentioned in bug 375249, comment #3. Sorry I didn't realize it wasn't clearly mentioned in this bug.
Comment 22 Jay Arthanareeswaran CLA 2012-05-28 05:52:19 EDT
(In reply to comment #21)
> The workaround is same as the one you mentioned in bug 375249, comment #3.
> Sorry I didn't realize it wasn't clearly mentioned in this bug.

To elaborate, try these steps:
1. Close the project in question.
2. Delete the invalidArchivesCache
3. Restart the workspace and reopen the project

It's possible that the restarting the workspace could be avoided, but we would want to rule out other causes. Before reopening the workspace, ensure that the JAR in question is a valid archive.