Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 228354 - Folder deletion can cause incorrect project delta node flags if linked folders exist in project
Summary: Folder deletion can cause incorrect project delta node flags if linked folder...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Resources (show other bugs)
Version: 3.4   Edit
Hardware: PC All
: P3 critical (vote)
Target Milestone: 3.4.1   Edit
Assignee: Szymon Brandys CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-23 04:39 EDT by Andrew Konchakov CLA
Modified: 2008-08-21 10:23 EDT (History)
2 users (show)

See Also:
Szymon.Brandys: iplog+


Attachments
Test v01 (1.88 KB, patch)
2008-08-21 06:19 EDT, Szymon Brandys CLA
no flags Details | Diff
Test v01 &Fix (3.02 KB, patch)
2008-08-21 06:56 EDT, Szymon Brandys CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Konchakov CLA 2008-04-23 04:39:37 EDT
Build ID: 3.4M6 (I20080330-1350)

Steps To Reproduce:
1.create a project
2.create a folder linked to some folder outside the workspace
3.create a folder
4. delete folder created on step 3 - delta is fired, project delta node has DESCRIPTION flag set though no changes to description has been made.



More information:
The bug is introduced in org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Resource.java in revision 1.156.
Below are fragments from method deleteResource():

<<CITE START
		// if this is a linked resource or contains linked resources , remove their entries from the project description
		List links = findLinks();
.....
		//remove all deleted linked resources from the project description
		if (getType() != IResource.PROJECT && links != null) {
			Project project = (Project) getProject();
			ProjectDescription description = project.internalGetDescription();
			for (Iterator it = links.iterator(); it.hasNext();)
				description.setLinkLocation(((IResource) it.next()).getProjectRelativePath(), null);
			project.internalSetDescription(description, true);
			project.writeDescription(IResource.FORCE);
		}
<<CITE END
So if findLinks returns an emply list (not null) thi method will force setting description without actual changes to it.

And here's the findLinks:
<<CITE START
	/*
	 * Returns a list of all linked resources at or below this resource, or null if there
	 * are no links.
	 */
	private List findLinks() {
		Project project = (Project) getProject();
		ProjectDescription description = project.internalGetDescription();
		HashMap linkMap = description.getLinks();
		if (linkMap == null)
			return null;
		List links = new ArrayList();
		IPath myPath = getProjectRelativePath();
		for (Iterator it = linkMap.values().iterator(); it.hasNext();) {
			LinkDescription link = (LinkDescription) it.next();
			IPath linkPath = link.getProjectRelativePath();
			if (myPath.isPrefixOf(linkPath))
				links.add(workspace.newResource(project.getFullPath().append(linkPath), link.getType()));
		}
		return links;
	}
<<CITE END
It obviously can return an empty list despite it's description says that it should return nulls if no related links found.
The code which uses this method relies on the behaviour compliant to the description and there's only one place which calls this method so it can be changed in following way:
 
	/*
	 * Returns a list of all linked resources at or below this resource, or null if there
	 * are no links.
	 */
	private List findLinks() {
		Project project = (Project) getProject();
		ProjectDescription description = project.internalGetDescription();
		HashMap linkMap = description.getLinks();
		if (linkMap == null)
			return null;
		List links = null;
		IPath myPath = getProjectRelativePath();
		for (Iterator it = linkMap.values().iterator(); it.hasNext();) {
			LinkDescription link = (LinkDescription) it.next();
			IPath linkPath = link.getProjectRelativePath();
			if (myPath.isPrefixOf(linkPath)){
				if (links == null){
				     links = new ArrayList();
				}
				links.add(workspace.newResource(project.getFullPath().append(linkPath), link.getType()));
                        }
		}
		return links;
	}
Comment 1 Szymon Brandys CLA 2008-04-23 07:04:02 EDT
It is a general issue, not only MacOs one.
Comment 2 Szymon Brandys CLA 2008-08-21 06:19:08 EDT
Created attachment 110549 [details]
Test v01
Comment 3 Szymon Brandys CLA 2008-08-21 06:56:02 EDT
Created attachment 110552 [details]
Test v01 &Fix
Comment 4 Szymon Brandys CLA 2008-08-21 10:23:16 EDT
Released to R3_4_maintenance and HEAD.