mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Tolerate file/directory entry with the same name in .jar file to fix IDEA-227977 Project under network mount doesn't open anymore after upgrade to 2019.3
GitOrigin-RevId: 217830687336e2c41864e4d2deeaad171b0916c9
This commit is contained in:
committed by
intellij-monorepo-bot
parent
74021d421d
commit
d63be20d7c
Binary file not shown.
@@ -50,7 +50,7 @@ public abstract class ZipHandlerBase extends ArchiveHandler {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected Map<String, EntryInfo> buildEntryMapForZipFile(ZipFile zip) {
|
||||
protected Map<String, EntryInfo> buildEntryMapForZipFile(@NotNull ZipFile zip) {
|
||||
Map<String, EntryInfo> map = new ZipEntryMap(zip.size());
|
||||
map.put("", createRootEntry());
|
||||
|
||||
@@ -80,6 +80,7 @@ public abstract class ZipHandlerBase extends ArchiveHandler {
|
||||
EntryInfo info = map.get(entryName);
|
||||
if (info != null) return info;
|
||||
|
||||
entryName = StringUtil.trimStart(entryName, "/");
|
||||
Trinity<String, String, String> path = splitPathAndFix(entryName);
|
||||
EntryInfo parentInfo = getOrCreate(path.first, map, zip);
|
||||
if (".".equals(path.second)) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.intellij.openapi.vfs.local;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.application.ex.PathManagerEx;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.io.FileAttributes;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
@@ -17,6 +18,7 @@ import com.intellij.openapi.vfs.newvfs.BulkFileListener;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent;
|
||||
import com.intellij.openapi.vfs.newvfs.events.VFileEvent;
|
||||
import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import com.intellij.testFramework.fixtures.BareTestFixtureTestCase;
|
||||
import com.intellij.testFramework.rules.TempDirectory;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -297,6 +299,19 @@ public class JarFileSystemTest extends BareTestFixtureTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCrazyJarWithDuplicateEntriesMustNotCrashAnything() {
|
||||
String jarPath = PathManagerEx.getTestDataPath() + "/vfs/sample.jar";
|
||||
VirtualFile vFile = LocalFileSystem.getInstance().refreshAndFindFileByPath(jarPath);
|
||||
assertNotNull(vFile);
|
||||
|
||||
VirtualFile jarRoot = JarFileSystem.getInstance().getRootByLocal(vFile);
|
||||
assertNotNull(jarRoot);
|
||||
String[] children = JarFileSystem.getInstance().list(jarRoot);
|
||||
assertEquals("com", UsefulTestCase.assertOneElement(children));
|
||||
assertEquals("Hello.class", UsefulTestCase.assertOneElement(JarFileSystem.getInstance().list(jarRoot.findFileByRelativePath("com"))));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static VirtualFile findByPath(String path) {
|
||||
VirtualFile file = JarFileSystem.getInstance().findFileByPath(path);
|
||||
|
||||
Reference in New Issue
Block a user