Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFred Bricon2018-01-11 11:15:56 -0500
committerFred Bricon2018-01-11 11:15:56 -0500
commit00ca0dfed8127cbbaae96e061f2e195f056e258d (patch)
tree2a3f0cad4a7eae07bf4012560a6b65fda98fb974 /org.eclipse.m2e.core
parentb90c203960c23b8fba8195e58c72215797cdbe65 (diff)
downloadm2e-core-00ca0dfed8127cbbaae96e061f2e195f056e258d.tar.gz
m2e-core-00ca0dfed8127cbbaae96e061f2e195f056e258d.tar.xz
m2e-core-00ca0dfed8127cbbaae96e061f2e195f056e258d.zip
493295: prevent failure when trying to create a folder that already exists
Change-Id: Ia0ad60fddac839ab5f6e49835953f953770ff717 Signed-off-by: Fred Bricon <fbricon@gmail.com>
Diffstat (limited to 'org.eclipse.m2e.core')
-rw-r--r--org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java14
1 files changed, 12 insertions, 2 deletions
diff --git a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java
index f0a01d9a..b68edb9d 100644
--- a/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java
+++ b/org.eclipse.m2e.core/src/org/eclipse/m2e/core/internal/M2EUtils.java
@@ -23,6 +23,7 @@ import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -66,10 +67,19 @@ public class M2EUtils {
if(parent != null && !parent.exists()) {
createFolder((IFolder) parent, false, monitor);
}
- folder.create(true, true, null);
+ try {
+ if(!folder.exists()) {
+ folder.create(true, true, monitor);
+ }
+ } catch(CoreException ex) {
+ //Don't fail if the resource already exists, in case of a race condition
+ if(ex.getStatus().getCode() != IResourceStatus.RESOURCE_EXISTS) {
+ throw ex;
+ }
+ }
}
- if(folder.isAccessible() && derived) {
+ if(folder.isAccessible() && derived && !folder.isDerived()) {
folder.setDerived(true, monitor);
}
}

Back to the top