Skip to content

Commit

Permalink
try to fix Random failing NatureTest.testBug297871 eclipse-platform#1688
Browse files Browse the repository at this point in the history


Or at least log IOException if any

eclipse-platform#1688
  • Loading branch information
jukzi committed Feb 6, 2025
1 parent ad50c26 commit b1d1e4a
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ public ProjectDescription read(IProject target, boolean creation) throws CoreExc
String msg = NLS.bind(Messages.resources_readProjectMeta, target.getName());
error = new ResourceException(IResourceStatus.FAILED_READ_METADATA, target.getFullPath(), msg, e);
} catch (IOException ex) {
// ignore
Policy.log(ex);
}
if (error == null && description == null) {
String msg = NLS.bind(Messages.resources_readProjectMeta, target.getName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,35 @@
package org.eclipse.core.internal.resources;

import java.net.URI;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.internal.events.BuildCommand;
import org.eclipse.core.internal.utils.FileUtil;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.core.resources.IBuildConfiguration;
import org.eclipse.core.resources.ICommand;
import org.eclipse.core.resources.IDynamicReferenceProvider;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;

public class ProjectDescription extends ModelObject implements IProjectDescription {
// constants
Expand Down Expand Up @@ -100,7 +122,7 @@ public class ProjectDescription extends ModelObject implements IProjectDescripti

// fields
protected URI location = null;
protected String[] natures = EMPTY_STRING_ARRAY;
protected volatile String[] natures = EMPTY_STRING_ARRAY;
protected URI snapshotLocation = null;

public ProjectDescription() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,12 +277,13 @@ public void testBug297871() throws Throwable {
assertHasEnabledNature(NATURE_EARTH);
assertThat(project.getNature(NATURE_EARTH)).isNotNull();

Files.copy(descTmp.toPath(), desc.toPath(), StandardCopyOption.REPLACE_EXISTING);
// Make sure enough time has past to bump file's
// timestamp during the copy
Thread.sleep(1000);

Files.copy(descTmp.toPath(), desc.toPath(), StandardCopyOption.REPLACE_EXISTING);
org.eclipse.core.tests.resources.ResourceTestUtil
.touchInFilesystem(project.getFile(IProjectDescription.DESCRIPTION_FILE_NAME));

// should read file from filesystem, creating new IProjectDescription:
project.refreshLocal(IResource.DEPTH_INFINITE, createTestMonitor());
assertDoesNotHaveNature(NATURE_EARTH);
assertThat(project.getNature(NATURE_EARTH)).isNull();
Expand Down

0 comments on commit b1d1e4a

Please sign in to comment.