diff options
2 files changed, 48 insertions, 41 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 6c6830525..d1bb037e9 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 @@ -23,6 +23,8 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.sourcelookup.ISourceContainerType; import org.eclipse.debug.internal.core.sourcelookup.SourceLookupMessages; @@ -77,6 +79,7 @@ public class ExternalArchiveSourceContainer extends AbstractSourceContainer { public Object[] findSourceElements(String name) throws CoreException { name = name.replace('\\', '/'); ZipFile file = getArchive(); + // NOTE: archive can be closed between get (above) and synchronized block (below) synchronized (file) { boolean isQualfied = name.indexOf('/') > 0; if (fDetectRoots && isQualfied) { @@ -86,7 +89,14 @@ public class ExternalArchiveSourceContainer extends AbstractSourceContainer { } } else { // try exact match - ZipEntry entry = file.getEntry(name); + ZipEntry entry = null; + try { + entry = file.getEntry(name); + } catch (IllegalStateException e) { + // archive was closed between retrieving and locking + throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), + e.getMessage(), e)); + } if (entry != null) { // can't be any duplicates if there is an exact match return new Object[]{new ZipEntryStorage(file, entry)}; @@ -127,28 +137,34 @@ public class ExternalArchiveSourceContainer extends AbstractSourceContainer { * @param name file name * @exception CoreException if an exception occurs while detecting the root */ - private ZipEntry searchRoots(ZipFile file, String name) { + private ZipEntry searchRoots(ZipFile file, String name) throws CoreException { if (fPotentialRoots == null) { fPotentialRoots = new HashSet(); fPotentialRoots.add(""); //$NON-NLS-1$ // all potential roots are the directories - Enumeration entries = file.entries(); - while (entries.hasMoreElements()) { - ZipEntry entry = (ZipEntry) entries.nextElement(); - if (entry.isDirectory()) { - fPotentialRoots.add(entry.getName()); - } else { - String entryName = entry.getName(); - int index = entryName.lastIndexOf("/"); //$NON-NLS-1$ - while (index > 0) { - if (fPotentialRoots.add(entryName.substring(0, index + 1))) { - entryName = entryName.substring(0, index); - index = entryName.lastIndexOf("/"); //$NON-NLS-1$ - } else { - break; + try { + Enumeration entries = file.entries(); + while (entries.hasMoreElements()) { + ZipEntry entry = (ZipEntry) entries.nextElement(); + if (entry.isDirectory()) { + fPotentialRoots.add(entry.getName()); + } else { + String entryName = entry.getName(); + int index = entryName.lastIndexOf("/"); //$NON-NLS-1$ + while (index > 0) { + if (fPotentialRoots.add(entryName.substring(0, index + 1))) { + entryName = entryName.substring(0, index); + index = entryName.lastIndexOf("/"); //$NON-NLS-1$ + } else { + break; + } } } } + } catch (IllegalStateException e) { + // archive was closed between retrieving and locking + throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), + e.getMessage(), e)); } } int i = 0; diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameSourceDisplayAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameSourceDisplayAdapter.java index 917f2b5c5..a12c36ce5 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameSourceDisplayAdapter.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/elements/adapters/StackFrameSourceDisplayAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -79,8 +79,6 @@ public class StackFrameSourceDisplayAdapter implements ISourceDisplay { }); } - - private SourceLookupJob fSourceLookupJob = new SourceLookupJob(); /** * A job to perform source lookup on the currently selected stack frame. */ @@ -93,18 +91,15 @@ public class StackFrameSourceDisplayAdapter implements ISourceDisplay { /** * Constructs a new source lookup job. */ - public SourceLookupJob() { + public SourceLookupJob(IStackFrame frame, ISourceLocator locator, IWorkbenchPage page) { super("Debug Source Lookup"); //$NON-NLS-1$ setPriority(Job.INTERACTIVE); setSystem(true); - } - - public void setLookupInfo(IStackFrame frame, ISourceLocator locator, IWorkbenchPage page) { fTarget = frame; fLocator = locator; fPage = page; } - + /* (non-Javadoc) * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) */ @@ -121,36 +116,35 @@ public class StackFrameSourceDisplayAdapter implements ISourceDisplay { fPrevFrame = lookupFrame; } if (!monitor.isCanceled() && fPage != null && !lookupFrame.isTerminated()) { - fSourceDisplayJob.setDisplayInfo(result, fPage); - fSourceDisplayJob.schedule(); + new SourceDisplayJob(result, fPage).schedule(); } } - setLookupInfo(null, null, null); } return Status.OK_STATUS; } + /* (non-Javadoc) + * @see org.eclipse.core.runtime.jobs.Job#belongsTo(java.lang.Object) + */ + public boolean belongsTo(Object family) { + return getClass().equals(family); + } + } - private SourceDisplayJob fSourceDisplayJob = new SourceDisplayJob(); class SourceDisplayJob extends UIJob { private ISourceLookupResult fResult; private IWorkbenchPage fPage; - public SourceDisplayJob() { + public SourceDisplayJob(ISourceLookupResult result, IWorkbenchPage page) { super("Debug Source Display"); //$NON-NLS-1$ setSystem(true); setPriority(Job.INTERACTIVE); - } - - /** - * Constructs a new source display job - */ - public synchronized void setDisplayInfo(ISourceLookupResult result, IWorkbenchPage page) { fResult = result; fPage = page; } + /* (non-Javadoc) * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) @@ -161,7 +155,6 @@ public class StackFrameSourceDisplayAdapter implements ISourceDisplay { synchronized (this) { result = fResult; page = fPage; - setDisplayInfo(null, null); } if (!monitor.isCanceled() && result != null && page != null) { DebugUITools.displaySource(result, page); @@ -186,11 +179,9 @@ public class StackFrameSourceDisplayAdapter implements ISourceDisplay { IStackFrame frame = (IStackFrame)context; if (!force && frame.equals(fPrevFrame)) { fPrevResult.updateArtifact(context); - fSourceDisplayJob.setDisplayInfo(fPrevResult, page); - fSourceDisplayJob.schedule(); + new SourceDisplayJob(fPrevResult, page).schedule(); } else { - fSourceLookupJob.setLookupInfo(frame, frame.getLaunch().getSourceLocator(), page); - fSourceLookupJob.schedule(); + new SourceLookupJob(frame, frame.getLaunch().getSourceLocator(), page).schedule(); } } @@ -226,7 +217,7 @@ public class StackFrameSourceDisplayAdapter implements ISourceDisplay { if (fPrevFrame.getDebugTarget().equals(target)) { fPrevFrame = null; fPrevResult = null; - fSourceDisplayJob.cancel(); + Job.getJobManager().cancel(SourceLookupJob.class); } } } |