Bug 552481 - New C Project wizard fails to overwrite existing project with same name but different case
Summary: New C Project wizard fails to overwrite existing project with same name but d...
Status: RESOLVED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 9.4.3   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: 9.10.0   Edit
Assignee: Jonah Graham CLA
QA Contact: Jonah Graham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-28 09:40 EDT by Sebastien Leblanc CLA
Modified: 2019-11-14 09:58 EST (History)
2 users (show)

See Also:


Attachments
screenshot of what user will see with proposed gerrits (31.88 KB, image/png)
2019-11-13 13:06 EST, Jonah Graham CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sebastien Leblanc CLA 2019-10-28 09:40:55 EDT
How to reproduce:

1. Create a new C Project named "Test":
   - File/New/Project
   - Select C/C++ > C Project, then click Next
   - Set "Test" as Project name, select Executable > Empty Project with any existing toolchain
   - Click Finish

2. Delete the created project:
   - Select "Test" in the Project Explorer view and press "Suppr" key
   - In the opened "Delete Resources" dialog, do not check the "Delete project contents on disk" check-box and click OK

3. Create a new C Project named "test" (same name but different case):
   - File/New/Project
   - Select C/C++ > C Project, then click Next
   - Set "test" as Project name, select Executable > Empty Project with any existing toolchain
   - Click Finish
   - In the opened "Old project will be overridden" dialog, indicating "OK to override ?", click OK.

The project is not created and the New C Project Wizard is not exited as it should.

Note that the same actions executed using the New Java Project wizard do not show such issue.
Comment 1 Jonah Graham CLA 2019-11-12 15:01:37 EST
There is an exception in the log for this error:

!SUBENTRY 1 org.eclipse.core.resources 4 275 2019-11-12 14:59:18.215
!MESSAGE A resource exists on disk with a different case: 'D:\cdt\runtime-New_configuration\Test'.
!STACK 0
java.lang.Exception: A resource exists on disk with a different case: 'D:\cdt\runtime-New_configuration\Test'.
	at org.eclipse.core.internal.resources.ResourceException.provideStackTrace(ResourceException.java:42)
	at org.eclipse.core.internal.resources.ResourceException.<init>(ResourceException.java:38)
	at org.eclipse.core.internal.resources.Project.assertCreateRequirements(Project.java:69)
	at org.eclipse.core.internal.resources.Project.create(Project.java:267)
	at org.eclipse.core.internal.resources.Project.create(Project.java:251)
	at org.eclipse.cdt.core.CCorePlugin$2.run(CCorePlugin.java:967)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2295)
	at org.eclipse.cdt.core.CCorePlugin.createCDTProject(CCorePlugin.java:962)

Now to understand how JDT deals with this issue.
Comment 2 Jonah Graham CLA 2019-11-12 15:05:00 EST
(In reply to Sebastien Leblanc from comment #0)
> Note that the same actions executed using the New Java Project wizard do not show such issue.

What I see with JDT is an error when I try to use same name, but different case "The name of the new project must ...". AFAICT, based on this SO question it has been like that for a long time. https://stackoverflow.com/questions/19749154/the-name-of-the-project-must-be-issue

Sebastien, do you see different behaviour with a Java project?
Comment 3 Jonah Graham CLA 2019-11-12 15:27:07 EST
I think 

org.eclipse.ui.dialogs.WizardNewProjectCreationPage.validatePage() would be a generic place to make this change so that not every project wizard in the Eclipse universe needs to make the same change. 

JDT sets the error here:
org.eclipse.jdt.ui.wizards.NewJavaProjectWizardPageOne.Validator.update(Observable, Object)

			IPath projectLocation= ResourcesPlugin.getWorkspace().getRoot().getLocation().append(name);
			if (projectLocation.toFile().exists()) {
				try {
Comment 4 Sebastien Leblanc CLA 2019-11-13 04:13:23 EST
(In reply to Jonah Graham from comment #2)
> What I see with JDT is an error when I try to use same name, but different
> case "The name of the new project must ...". AFAICT, based on this SO
> question it has been like that for a long time.
> https://stackoverflow.com/questions/19749154/the-name-of-the-project-must-be-
> issue
> 
> Sebastien, do you see different behaviour with a Java project?

Hi Jonah,
I observe the same indeed.

I agree with your proposal in Comment 3: find a generic place to handle this case in every New Project Wizards.
Comment 5 Eclipse Genie CLA 2019-11-13 12:59:11 EST
New Gerrit change created: https://git.eclipse.org/r/152594
Comment 6 Eclipse Genie CLA 2019-11-13 12:59:59 EST
New Gerrit change created: https://git.eclipse.org/r/152595
Comment 7 Jonah Graham CLA 2019-11-13 13:06:20 EST
I have come to the conclusion that I cannot put the generic error handling in org.eclipse.ui.dialogs.WizardNewProjectCreationPage.validatePage() as the logic there can't easily error out in this case without impacting other users.

Instead I looked as to why, as a user, the notification of the error was lost. I found that other wizards (such as PDE's Feature wizard), display an error on finish. 

I have therefore reviewed the project wizards to try to make sure we are not swallowing, or only logging such errors. Indeed, some of the wizards simply re-raised a RuntimeException to get around the notification issue. In this case the exception we want to display is a resource exception which helpfully says: "A resource exists on disk with a different case".
Comment 8 Jonah Graham CLA 2019-11-13 13:06:47 EST
Created attachment 280630 [details]
screenshot of what user will see with proposed gerrits