[Win32] Folder becomes a file in the workspace tree when a child is deleted during `refreshLocal` (regression in 2026-09)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 15/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- java
- Lĩnh vực
- operating-systems
Hướng nghiên cứu
Start with Win32Handler.fetchFileInfo and the listDirectoryAndGetFileInfos override, then LocalFile.childInfos and LocalFile.fetchInfo, to see where the name is left unset when a child disappears. Pull request #3025 already targets this, so review it before touching code. Done means the race test RefreshRaceTest no longer yields an empty-name entry and refreshLocal keeps the folder a folder.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Since Eclipse 2026-09 (org.eclipse.core.filesystem 1.11.500), IResource#refreshLocal can turn an existing folder into an IFile in the workspace tree. This happens when one of the folder's children is deleted while the refresh is listing it. On disk the folder is still a directory, but the workspace treats it as a file. After that, creating anything below it fails:
org.eclipse.core.internal.resources.ResourceException: Resource '/P/work' does not exist.
at org.eclipse.core.internal.resources.Resource.checkExists
at org.eclipse.core.internal.resources.Folder.assertCreateRequirements
at org.eclipse.core.internal.resources.Folder.create
If the race happens directly below the project, AssertionFailedException: Path must include project and resource name is thrown instead.
With auto-refresh enabled, the refresh monitor usually turns the file back into a folder (fileToFolder) a little later. That makes the failure flaky.
Root cause
LocalFile.childInfos()now goes throughLocalFileNativesManager.listDirectoryAndGetFileInfos→NativeHandler.listDirectoryAndGetFileInfos(introduced in #2787). It gets the names fromFile.list()and then callsfetchFileInfo(dir + File.separator + name)for each one.- If a child is deleted between
File.list()and the native lookup,Win32Handler.fetchFileInfo(FindFirstFileW→ERROR_FILE_NOT_FOUND) returns aFileInfowith an empty name,exists=falseand no error code. Unlike the old code path (FileStore.childInfos→LocalFile.fetchInfo), the name is never filled in. - During
refreshLocal:UnifiedTree.getLocalListsorts the""entry first.createChildNodeFromFileSystemappends""to the parent path, which produces a file node at the folder's own path.RefreshLocalVisitor.synchronizeExistencesees a gender variant, andsynchronizeGendercallsfolderToFile.
The Win32Handler override of listDirectoryAndGetFileInfos added in #2952 has the same flaw: it also leaves the name unset on NoSuchFileException.
Suggested fix
The other implementations of NativeHandler.fetchFileInfo(String) all seem to ensure that the returned fileinfo has a filename set, only the Win32Handler does not seem to have such a case and relies on the callers of fetchFileInfo (e.g. LocalFile.fetchInfo(int, IProgressMonitor) to fix this. So maybe we should also make sure the Win32Handler always sets name?
Steps to reproduce
Windows only. The following JUnit 5 test fails reliably within the first few attempts. Test 1 checks the filesystem layer only. Test 2 shows the symptom through the Workspace API.
package org.eclipse.core.tests.filesystem;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.filesystem.EFS;
import org.eclipse.core.filesystem.IFileInfo;
import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
class RefreshRaceTest {
@TempDir
Path tempDir;
IProject project;
@AfterEach
void afterEach() throws Exception {
if (project != null) {
project.delete(true, true, null);
setAutoRefresh(true);
}
}
@Test
void childInfosNeverReturnsNamelessEntry() throws Exception {
IFileStore store = EFS.getLocalFileSystem().getStore(tempDir.toUri());
race(tempDir, () -> {
for (IFileInfo info : store.childInfos(EFS.NONE, null)) {
Assertions.assertFalse(info.getName().isEmpty(), "entry with empty name: " + info);
}
});
}
@Test
void refreshLocalKeepsFolderAFolder() throws Exception {
setAutoRefresh(false); // the refresh monitor would undo the damage
project = ResourcesPlugin.getWorkspace().getRoot().getProject("P");
project.create(null);
project.open(null);
IFolder folder = project.getFolder("work");
folder.create(true, true, null);
race(folder.getLocation().toPath(), () -> {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
Assertions.assertInstanceOf(IFolder.class, project.findMember("work"));
});
folder.getFolder("data").create(true, true, null);
}
/** Fills dir with files and runs probe while another thread deletes them. */
static void race(Path dir, Probe probe) throws Exception {
for (int attempt = 0; attempt < 20; attempt++) {
List<Path> files = new ArrayList<>();
for (int i = 0; i < 2000; i++) {
files.add(Files.createFile(dir.resolve("file" + i + ".tmp")));
}
Thread deleter = new Thread(() -> files.forEach(f -> f.toFile().delete()));
deleter.start();
while (deleter.isAlive()) {
probe.run();
}
deleter.join();
}
}
static void setAutoRefresh(boolean value) throws Exception {
IEclipsePreferences prefs = InstanceScope.INSTANCE.getNode(ResourcesPlugin.PI_RESOURCES);
prefs.putBoolean(ResourcesPlugin.PREF_AUTO_REFRESH, value);
prefs.flush();
}
interface Probe {
void run() throws CoreException;
}
}
Failures observed:
entry with empty name: FileInfo [name=, length=0, lastModified=0, exists=false, attributes=12582912, errorCode=0]
expected: <org.eclipse.core.resources.IFolder> but was: <org.eclipse.core.internal.resources.File>
Disclaimer: I had Claude write this up but debugged most of it manually.
Overall I think that the temporary corruption of the resource tree is a quite a nasty bug.
/cc @HannesWell @iloveeclipse
- Ngôn ngữ chính
- Java
- Star
- 165
- Fork
- 174
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 42
Chuẩn bị môi trường
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của eclipse-platform/eclipse.platform
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
eclipse-platform/eclipse.platform#3019 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
eclipse-platform/eclipse.platform#2940 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Terminal views all show same name 'Terminal' in Ctrl+F7 view switcher popupCó thể đã có người làm @ravnskjaer đã nhận 7 ngày trước. Đang mởbug good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
eclipse-platform/eclipse.platform#2774 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
eclipse-platform/eclipse.platform#2593 · 7 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
JGit runtime logs are spamming debugger consoleCó thể đã có người làm @HannesWell đã nhận 1 ngày trước. Đang mởbug regression
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 56/100
eclipse-platform/eclipse.platform#3022 · 17 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của eclipse-platform/eclipse.platform
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
apache/rocketmq-dashboard#6872 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ADORSYS-GIS/token-status-link#168 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
ADORSYS-GIS/keycloak-oid4vp-plugin#232 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Wrong link to test resultsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
docs(site): Mermaid edge-label contrast on Architecture and a table header on How it comparesĐang mởdocumentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
devops-thiago/ThrillhouseBot#1132 ·
Maintainer thường phản hồi trong vòng 1 ngày