Skip to content

Commit

Permalink
Don't close a ZipEntryStorage archive file when obtaining its name
Browse files Browse the repository at this point in the history
Revert "Bug 558863 - Possible Recource leak warning in
SourceElementQualifierProvider"

This reverts commit 876dd12.

Fixes eclipse-platform/eclipse.platform.ui#2251
  • Loading branch information
HannesWell committed Sep 11, 2024
1 parent 8c1b934 commit f89dcb7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
org.eclipse.search;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui.forms;bundle-version="[3.4.0,4.0.0)",
org.eclipse.core.resources,
org.eclipse.debug.core;bundle-version="[3.12.0,4.0.0)"
org.eclipse.debug.core;bundle-version="[3.22.0,4.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-17
Automatic-Module-Name: org.eclipse.jdt.debug.ui
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2020 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -15,12 +15,10 @@


import java.io.File;
import java.io.IOException;
import java.util.zip.ZipFile;
import java.nio.file.Path;

import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.debug.core.sourcelookup.containers.ZipEntryStorage;
import org.eclipse.jdt.core.IJavaElement;
Expand Down Expand Up @@ -49,25 +47,17 @@ public String getText(Object element) {
if (element instanceof IJavaElement) {
IJavaElement parent = ((IJavaElement)element).getParent();
return fJavaLabels.getText(parent);
} else if (element instanceof ZipEntryStorage) {
ZipEntryStorage storage = (ZipEntryStorage)element;
try (ZipFile archive = storage.getArchive()) {
String zipFileName = archive.getName();
IPath path = new Path(zipFileName);
IRuntimeClasspathEntry entry = JavaRuntime.newArchiveRuntimeClasspathEntry(path);
IResource res = entry.getResource();
if (res == null) {
// external
return zipFileName;
}
// internal
return res.getName();
} catch (IOException e) {
e.printStackTrace();
} else if (element instanceof ZipEntryStorage storage) {
Path zipFile = storage.getArchivePath();
IPath path = IPath.fromPath(zipFile);
IRuntimeClasspathEntry entry = JavaRuntime.newArchiveRuntimeClasspathEntry(path);
IResource res = entry.getResource();
if (res == null) {
// external
return zipFile.toString();
}
// ZipFile archive = storage.getArchive();
// String zipFileName = archive.getName();

// internal
return res.getName();
} else if (element instanceof LocalFileStorage) {
LocalFileStorage storage = (LocalFileStorage)element;
File extFile = storage.getFile();
Expand Down

0 comments on commit f89dcb7

Please sign in to comment.