From b115fd5bd86cacbffcbaaa7425af7cb14f792c91 Mon Sep 17 00:00:00 2001 From: Andrey Loskutov Date: Fri, 28 Apr 2017 11:31:26 +0200 Subject: Bug 515941 - ConcurrentModificationException in ExternalArchiveSourceContainer Don't try to dispose while the search is running, don't continue with search if container was disposed. Change-Id: Ida0e5e07a5cafe5bdab4096e991bacb13c8872bd Signed-off-by: Andrey Loskutov --- .../containers/ExternalArchiveSourceContainer.java | 23 ++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/ExternalArchiveSourceContainer.java b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/ExternalArchiveSourceContainer.java index bd1858a25..de702e7c5 100644 --- a/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/ExternalArchiveSourceContainer.java +++ b/org.eclipse.debug.core/core/org/eclipse/debug/core/sourcelookup/containers/ExternalArchiveSourceContainer.java @@ -42,10 +42,11 @@ import com.ibm.icu.text.MessageFormat; */ public class ExternalArchiveSourceContainer extends AbstractSourceContainer { - private boolean fDetectRoots = false; - private Set fPotentialRoots = null; + private boolean fDisposed; + private boolean fDetectRoots; + private Set fPotentialRoots; private List fRoots = new ArrayList(); - private String fArchivePath = null; + private String fArchivePath; /** * Unique identifier for the external archive source container type * (value org.eclipse.debug.core.containerType.externalArchive). @@ -79,6 +80,9 @@ public class ExternalArchiveSourceContainer extends AbstractSourceContainer { public Object[] findSourceElements(String name) throws CoreException { String newname = name.replace('\\', '/'); ZipFile file = getArchive(); + if (file == null) { + return EMPTY; + } // NOTE: archive can be closed between get (above) and synchronized block (below) synchronized (file) { boolean isQualfied = newname.indexOf('/') > 0; @@ -138,7 +142,10 @@ public class ExternalArchiveSourceContainer extends AbstractSourceContainer { * @return the {@link ZipEntry} with the given name or null * @exception CoreException if an exception occurs while detecting the root */ - private ZipEntry searchRoots(ZipFile file, String name) throws CoreException { + private synchronized ZipEntry searchRoots(ZipFile file, String name) throws CoreException { + if (fDisposed) { + return null; + } if (fPotentialRoots == null) { fPotentialRoots = new HashSet(); fPotentialRoots.add(""); //$NON-NLS-1$ @@ -208,7 +215,10 @@ public class ExternalArchiveSourceContainer extends AbstractSourceContainer { * * @throws CoreException if unable to access the archive */ - private ZipFile getArchive() throws CoreException { + private synchronized ZipFile getArchive() throws CoreException { + if (fDisposed) { + return null; + } try { return SourceLookupUtils.getZipFile(fArchivePath); } catch (IOException e) { @@ -255,11 +265,12 @@ public class ExternalArchiveSourceContainer extends AbstractSourceContainer { } @Override - public void dispose() { + public synchronized void dispose() { super.dispose(); if (fPotentialRoots != null) { fPotentialRoots.clear(); } fRoots.clear(); + fDisposed = true; } } -- cgit v1.2.3