Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 322406

Summary: [launch] Calling rename() and setContainer in a single save cycle results in multiple shared configurations
Product: [Eclipse Project] Platform Reporter: Michael Rennie <Michael_Rennie>
Component: DebugAssignee: Platform-Debug-Inbox <platform-debug-inbox>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: curtis.windatt.public, darin.eclipse, pawel.1.piech
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug

Description Michael Rennie CLA 2010-08-11 13:03:13 EDT
code from HEAD

If you happen to call ILaunchConfigurationWorkingCopy.rename(..) and ILaunchConfigurationWorkingCopy.setContaner(..) in a single save cycle the call to ILaunchConfigurationWorkingCopy.doSave() will result in two configurations.

The problem is that the rename + container cause the config to be considered as moved, and during the save when we try to delete the original it fails because the backing IFile no longer exists.

Here is a test that demonstrates the problem (from Drain W):

public void testRenameAndSetContainer() throws CoreException { 
  IProject project = getProject(); 
  IFolder f1 = project.getFolder("f1"); 
  IFolder f2 = project.getFolder("f2"); 
  f1.create(false, true, null); 
  f2.create(false, true, null); 
  ILaunchConfigurationWorkingCopy wc = newConfiguration(f1, "start-here"); 
  ILaunchConfiguration orig = wc.doSave(); 
   
  wc.setContainer(f2); 
  wc.rename("end-here"); 
  ILaunchConfiguration next = wc.doSave(); 
   
  assertFalse("Original should not exist", orig.exists()); 
  assertTrue("Renamed and moved config should exist", next.exists()); 
   
 }
Comment 1 Darin Wright CLA 2010-08-11 13:13:45 EDT
The test was flawed... it passes as follows (get the new working copy after the original save).

public void testRenameAndSetContainer() throws CoreException {
	IProject project = getProject();
	IFolder f1 = project.getFolder("f1");
	IFolder f2 = project.getFolder("f2");
	f1.create(false, true, null);
	f2.create(false, true, null);
	ILaunchConfigurationWorkingCopy wc = newConfiguration(f1, "start-here");
	ILaunchConfiguration orig = wc.doSave();
	wc = orig.getWorkingCopy();

	wc.setContainer(f2);
	wc.rename("end-here");
	ILaunchConfiguration next = wc.doSave();
	
	assertFalse("Original should not exist", orig.exists());
	assertTrue("Renamed and moved config should exist", next.exists());
	
}

However, a problem does occur when a project is renamed.
Comment 2 Michael Rennie CLA 2010-08-11 13:15:04 EDT
Steps to reproduce in the IDE

1. create a project and create an Ant build file
2. create a configuration for the build file and share it in the project
3. rename the project

Expected:

the config is renamed and all is well

Happens:

the config is renamed but now there will be two of them - one referencing the
original project and one referencing the new project.
Comment 3 Lars Vogel CLA 2019-11-14 03:28:27 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

If the bug is still relevant, please remove the "stalebug" whiteboard tag.