Bug 191931 - BatchImageBuilder sometimes marks resources as derived before deleting them
Summary: BatchImageBuilder sometimes marks resources as derived before deleting them
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC All
: P3 normal (vote)
Target Milestone: 3.4 M3   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-11 07:54 EDT by Maxime Daniel CLA
Modified: 2007-10-29 05:11 EDT (History)
0 users

See Also:


Attachments
Proposed patch (972 bytes, patch)
2007-10-03 13:06 EDT, Kent Johnson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Maxime Daniel CLA 2007-06-11 07:54:27 EDT
Source code based, v_770.

Noticed that at BatchImageBuilder#101-110 we marked resources as derived before deleting them, which seemed sub-optimal to me (argument being that it is worthless to modify a resource you're about to delete). Discussed the point with Kent, who told me that the intent here is to make sure that delete deltas generated by the subsequent delete are properly marked as concerning derived resources. Since we 'own' output folders in this case (see surrounding test of the compiler option), the argument is that the resources we delete there *must* be derived, at least when they are seen from the listeners who get the delete delta.

I've pondered a bit on this since and I still see a couple of problems with the approach:
- it is not thread-safe; while the window of opportunity is short, another thread could still change the derived flag on the resource; this is admittedly very unlikely, but, this would still raise the question about another thread producing new files while we are deleting the output folder contents; the question here is: would there be other means to express the 'JDT owns the output folders' statement, in a way that would be more proactive and cost effective? else, would it be possible to ensure proper transactional properties on the delete action?
- the case of source folders that are also output folders is not handled consistently with the case of a dedicated output folder per source folder: line 136, we merely delete whatever file that is named as a class file without enforcing it to be marked as derived, which could lead to delete deltas without the derived mark if I get it well (provided that someone else dumps files that have class file names but are not marked as derived).

Opened this bug to keep the discussion flowing.
Comment 1 Kent Johnson CLA 2007-10-03 13:04:41 EDT
1. No other job in Eclipse can manipulate resources while a build is running and the derived flag is a resource based flag. If another tool outside of Eclipse adds more .class files, then these files appear after the next refresh operation and will be seen by the next build.

We're checking the status of the 'derived' flag only to ensure that additional .class files, which can be added to the output folder by other tools, are tagged appropriately. All .class files generated by our builder will be tagged so its only additional files that may need to be tagged, so the performance concern should only surface in the case where numerous additional .class files have been added.

2. Addressed the second point by adding a new check to ensure .class files in a source folder are also tagged as derived.
Comment 2 Kent Johnson CLA 2007-10-03 13:06:35 EDT
Created attachment 79657 [details]
Proposed patch
Comment 3 Frederic Fusier CLA 2007-10-29 05:11:54 EDT
Code verified for 3.4M3 using I20071029-0010 build.