Skip to content

Commit 87a5e5a

Browse files
Jörg Kubitzjukzi
Jörg Kubitz
authored andcommitted
try to fix Random failing NatureTest.testBug297871 eclipse-platform#1688
Or at least log IOException if any eclipse-platform#1688
1 parent b085177 commit 87a5e5a

File tree

3 files changed

+31
-8
lines changed

3 files changed

+31
-8
lines changed

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/FileSystemResourceManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ public ProjectDescription read(IProject target, boolean creation) throws CoreExc
972972
String msg = NLS.bind(Messages.resources_readProjectMeta, target.getName());
973973
error = new ResourceException(IResourceStatus.FAILED_READ_METADATA, target.getFullPath(), msg, e);
974974
} catch (IOException ex) {
975-
// ignore
975+
Policy.log(ex);
976976
}
977977
if (error == null && description == null) {
978978
String msg = NLS.bind(Messages.resources_readProjectMeta, target.getName());

resources/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/ProjectDescription.java

+26-4
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,35 @@
1919
package org.eclipse.core.internal.resources;
2020

2121
import java.net.URI;
22-
import java.util.*;
22+
import java.util.ArrayList;
23+
import java.util.Arrays;
24+
import java.util.Collection;
25+
import java.util.Collections;
26+
import java.util.HashMap;
27+
import java.util.LinkedHashSet;
28+
import java.util.LinkedList;
29+
import java.util.List;
30+
import java.util.Map;
2331
import java.util.Map.Entry;
32+
import java.util.Set;
2433
import org.eclipse.core.filesystem.URIUtil;
2534
import org.eclipse.core.internal.events.BuildCommand;
2635
import org.eclipse.core.internal.utils.FileUtil;
27-
import org.eclipse.core.resources.*;
28-
import org.eclipse.core.runtime.*;
36+
import org.eclipse.core.resources.IBuildConfiguration;
37+
import org.eclipse.core.resources.ICommand;
38+
import org.eclipse.core.resources.IDynamicReferenceProvider;
39+
import org.eclipse.core.resources.IProject;
40+
import org.eclipse.core.resources.IProjectDescription;
41+
import org.eclipse.core.resources.ResourcesPlugin;
42+
import org.eclipse.core.runtime.Assert;
43+
import org.eclipse.core.runtime.CoreException;
44+
import org.eclipse.core.runtime.IConfigurationElement;
45+
import org.eclipse.core.runtime.IExtension;
46+
import org.eclipse.core.runtime.IPath;
47+
import org.eclipse.core.runtime.IProgressMonitor;
48+
import org.eclipse.core.runtime.IStatus;
49+
import org.eclipse.core.runtime.Platform;
50+
import org.eclipse.core.runtime.Status;
2951

3052
public class ProjectDescription extends ModelObject implements IProjectDescription {
3153
// constants
@@ -100,7 +122,7 @@ public class ProjectDescription extends ModelObject implements IProjectDescripti
100122

101123
// fields
102124
protected URI location = null;
103-
protected String[] natures = EMPTY_STRING_ARRAY;
125+
protected volatile String[] natures = EMPTY_STRING_ARRAY;
104126
protected URI snapshotLocation = null;
105127

106128
public ProjectDescription() {

resources/tests/org.eclipse.core.tests.resources/src/org/eclipse/core/tests/resources/NatureTest.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -277,12 +277,13 @@ public void testBug297871() throws Throwable {
277277
assertHasEnabledNature(NATURE_EARTH);
278278
assertThat(project.getNature(NATURE_EARTH)).isNotNull();
279279

280+
Files.copy(descTmp.toPath(), desc.toPath(), StandardCopyOption.REPLACE_EXISTING);
280281
// Make sure enough time has past to bump file's
281282
// timestamp during the copy
282-
Thread.sleep(1000);
283-
284-
Files.copy(descTmp.toPath(), desc.toPath(), StandardCopyOption.REPLACE_EXISTING);
283+
org.eclipse.core.tests.resources.ResourceTestUtil
284+
.touchInFilesystem(project.getFile(IProjectDescription.DESCRIPTION_FILE_NAME));
285285

286+
// should read file from filesystem, creating new IProjectDescription:
286287
project.refreshLocal(IResource.DEPTH_INFINITE, createTestMonitor());
287288
assertDoesNotHaveNature(NATURE_EARTH);
288289
assertThat(project.getNature(NATURE_EARTH)).isNull();

0 commit comments

Comments
 (0)