Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
Bundle-Version: 3.23.100.qualifier
Bundle-Version: 3.23.200.qualifier
Bundle-Activator: org.eclipse.core.resources.ResourcesPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,6 +935,10 @@ private IFileStore getFileStore(IFile target, boolean force) throws ResourceExce
final IFileInfo fileInfo = store.fetchInfo();
Resource resource = (Resource) target;
ResourceInfo info = resource.getResourceInfo(true, false);
if (info == null) {
String message = NLS.bind(Messages.resources_mustExist, target.getFullPath());
throw new ResourceException(IResourceStatus.RESOURCE_NOT_FOUND, target.getFullPath(), message, null);
}
if (fileInfo.getLastModified() != info.getLocalSyncInfo()) {
asyncRefresh(target);
String message = NLS.bind(Messages.localstore_resourceIsOutOfSync, target.getFullPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Eclipse Core Tests Resources
Bundle-SymbolicName: org.eclipse.core.tests.resources; singleton:=true
Bundle-Version: 3.11.1100.qualifier
Bundle-Version: 3.11.1200.qualifier
Bundle-Vendor: Eclipse.org
Export-Package: org.eclipse.core.tests.filesystem,
org.eclipse.core.tests.internal.alias,
Expand Down
2 changes: 1 addition & 1 deletion resources/tests/org.eclipse.core.tests.resources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<version>4.39.0-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.core.tests.resources</artifactId>
<version>3.11.1100-SNAPSHOT</version>
<version>3.11.1200-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
*******************************************************************************/
package org.eclipse.core.tests.resources.regression;

import static java.lang.System.currentTimeMillis;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
import static org.eclipse.core.tests.resources.ResourceTestUtil.createInWorkspace;
Expand All @@ -24,14 +25,20 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceStatus;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform.OS;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.tests.resources.util.WorkspaceResetExtension;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -125,4 +132,82 @@ public void testBug43936() throws CoreException {
project.setDescription(desc, createTestMonitor());
}

/**
* Do not throw RuntimeException when accessing a deleted file
*/
@Test
public void testIssue2290() throws CoreException, InterruptedException {
IProject project = getWorkspace().getRoot().getProject("MyProject");
IFile subject = project.getFile("subject.txt");
Job noise = Job.create("Create/delete", monitor -> {
try {
while (!monitor.isCanceled()) {
createInWorkspace(subject);
while (!monitor.isCanceled()) {
try {
subject.delete(true, monitor);
break;
} catch (CoreException e) {
// On Windows, files opened for reading can't be deleted, try again
if (e.getStatus().getCode() != IResourceStatus.FAILED_DELETE_LOCAL) {
throw e;
}
}
}
}
} catch (CoreException e) {
return e.getStatus();
}
return Status.OK_STATUS;
});
noise.setPriority(Job.INTERACTIVE);

long stop = currentTimeMillis() + 1000;
try {
noise.schedule();
while (currentTimeMillis() < stop) {
assertContentAccessibleOrNotFound(subject); // should not throw
}
} finally {
noise.cancel();
noise.join();
IStatus result = noise.getResult();
if (!result.isOK()) {
throw new CoreException(result);
}
}
}

private void assertContentAccessibleOrNotFound(IFile file) {
try (InputStream contents = file.getContents(false)) {
contents.transferTo(OutputStream.nullOutputStream());
} catch (IOException e) {
throw new AssertionError(e);
} catch (CoreException e) {
switch (e.getStatus().getCode()) {
case IResourceStatus.RESOURCE_NOT_LOCAL:
case IResourceStatus.RESOURCE_NOT_FOUND:
case IResourceStatus.FAILED_READ_LOCAL:
case IResourceStatus.OUT_OF_SYNC_LOCAL:
break;
default:
throw new AssertionError(e);
}
}
try (InputStream contents = file.getContents(true)) {
contents.transferTo(OutputStream.nullOutputStream());
} catch (IOException e) {
throw new AssertionError(e);
} catch (CoreException e) {
switch (e.getStatus().getCode()) {
case IResourceStatus.RESOURCE_NOT_LOCAL:
case IResourceStatus.RESOURCE_NOT_FOUND:
case IResourceStatus.FAILED_READ_LOCAL:
break;
default:
throw new AssertionError(e);
}
}
}

}
Loading