mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
yet more diagnostics for VfsData.initFile exceptions (IDEA-CR-4584, EA-70830)
This commit is contained in:
@@ -144,8 +144,14 @@ public class VfsData {
|
||||
if (segment != null || !create) return segment;
|
||||
return ourSegments.cacheOrGet(key, new Segment());
|
||||
}
|
||||
|
||||
public static class FileAlreadyCreatedException extends Exception {
|
||||
private FileAlreadyCreatedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static void initFile(int id, Segment segment, int nameId, @NotNull Object data) {
|
||||
public static void initFile(int id, Segment segment, int nameId, @NotNull Object data) throws FileAlreadyCreatedException {
|
||||
assert id > 0;
|
||||
int offset = getOffset(id);
|
||||
|
||||
@@ -154,12 +160,12 @@ public class VfsData {
|
||||
Object existingData = segment.myObjectArray.get(offset);
|
||||
if (existingData != null) {
|
||||
int parent = FSRecords.getParent(id);
|
||||
String msg = "File already created: " + existingData + "; parentId=" + parent;
|
||||
String msg = "File already created: " + nameId + ", data=" + existingData + "; parentId=" + parent;
|
||||
if (parent > 0) {
|
||||
msg += "; parent.name=" + FSRecords.getName(parent);
|
||||
msg += "; parent.children=" + Arrays.toString(FSRecords.listAll(id));
|
||||
}
|
||||
throw new AssertionError(msg);
|
||||
throw new FileAlreadyCreatedException(msg);
|
||||
}
|
||||
segment.myObjectArray.set(offset, data);
|
||||
}
|
||||
|
||||
+7
-2
@@ -216,8 +216,13 @@ public class VirtualDirectoryImpl extends VirtualFileSystemEntry {
|
||||
private VirtualFileSystemEntry createChild(int nameId, int id, @NotNull NewVirtualFileSystem delegate) {
|
||||
final int attributes = ourPersistence.getFileAttributes(id);
|
||||
VfsData.Segment segment = VfsData.getSegment(id, true);
|
||||
VfsData.initFile(id, segment, nameId,
|
||||
PersistentFS.isDirectory(attributes) ? new VfsData.DirectoryData() : KeyFMap.EMPTY_MAP);
|
||||
try {
|
||||
VfsData.initFile(id, segment, nameId,
|
||||
PersistentFS.isDirectory(attributes) ? new VfsData.DirectoryData() : KeyFMap.EMPTY_MAP);
|
||||
}
|
||||
catch (VfsData.FileAlreadyCreatedException e) {
|
||||
throw new RuntimeException("dir=" + myId + "; dir.children=" + Arrays.toString(FSRecords.listAll(myId)), e);
|
||||
}
|
||||
LOG.assertTrue(!(getFileSystem() instanceof Win32LocalFileSystem));
|
||||
|
||||
VirtualFileSystemEntry child = VfsData.getFileById(id, this);
|
||||
|
||||
+2
-2
@@ -908,14 +908,14 @@ public class PersistentFSImpl extends PersistentFS implements ApplicationCompone
|
||||
try {
|
||||
VfsData.initFile(rootId, segment, -1, directoryData);
|
||||
}
|
||||
catch (AssertionError e) {
|
||||
catch (VfsData.FileAlreadyCreatedException e) {
|
||||
for (Map.Entry<String, VirtualFileSystemEntry> entry : myRoots.entrySet()) {
|
||||
final VirtualFileSystemEntry existingRoot = entry.getValue();
|
||||
if (Math.abs(existingRoot.getId()) == rootId) {
|
||||
throw new RuntimeException("Duplicate FS roots: " + rootUrl + " and " + entry.getKey() + ", id=" + rootId + ", valid=" + existingRoot.isValid(), e);
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("No root duplication, roots" + Arrays.toString(FSRecords.listAll(1)), e);
|
||||
throw new RuntimeException("No root duplication, roots=" + Arrays.toString(FSRecords.listAll(1)), e);
|
||||
}
|
||||
incStructuralModificationCount();
|
||||
mark = writeAttributesToRecord(rootId, 0, newRoot, fs, attributes);
|
||||
|
||||
Reference in New Issue
Block a user