mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Exceptions during shutdown cleanup.
This commit is contained in:
parent
1330da7323
commit
c5b151520f
5 changed files with 17 additions and 29 deletions
|
@ -53,7 +53,6 @@ public class DsfPlugin extends Plugin {
|
|||
* @see org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
|
||||
*/
|
||||
public void stop(BundleContext context) throws Exception {
|
||||
fgPlugin = null;
|
||||
fgBundleContext = null;
|
||||
super.stop(context);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@ import java.io.PrintStream;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
|
@ -61,30 +59,6 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
|||
return Thread.currentThread().equals( ((DsfThreadFactory)getThreadFactory()).fThread );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterExecute(Runnable r, Throwable t) {
|
||||
if (r instanceof Future) {
|
||||
Future<?> future = (Future<?>)r;
|
||||
try {
|
||||
/*
|
||||
* Try to retrieve the value, which should throw exception in
|
||||
* case when exception was thrown within the Runnable/Callable.
|
||||
* Must call isDone(), because scheduled futures would block
|
||||
* on get.
|
||||
*/
|
||||
if (future.isDone()) {
|
||||
future.get();
|
||||
}
|
||||
} catch (InterruptedException e) { // Ignore
|
||||
} catch (CancellationException e) { // Ignore also
|
||||
} catch (ExecutionException e) {
|
||||
if (e.getCause() != null) {
|
||||
logException(e.getCause());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void logException(Throwable t) {
|
||||
DsfPlugin plugin = DsfPlugin.getDefault();
|
||||
if (plugin == null) return;
|
||||
|
@ -224,6 +198,7 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
|||
final Runnable fRunnable;
|
||||
public TracingWrapperRunnable(Runnable runnable, int offset) {
|
||||
super(offset);
|
||||
if (runnable == null) throw new NullPointerException();
|
||||
fRunnable = runnable;
|
||||
|
||||
// Check if executable wasn't executed already.
|
||||
|
@ -239,7 +214,15 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
|||
traceExecution();
|
||||
|
||||
// Finally invoke the runnable code.
|
||||
fRunnable.run();
|
||||
try {
|
||||
fRunnable.run();
|
||||
} catch (RuntimeException e) {
|
||||
// If an exception was thrown in the Runnable, trace it.
|
||||
// Because there is no one else to catch it, it is a
|
||||
// programming error.
|
||||
logException(e);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,6 +230,7 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
|||
final Callable<T> fCallable;
|
||||
public TracingWrapperCallable(Callable<T> callable, int offset) {
|
||||
super(offset);
|
||||
if (callable == null) throw new NullPointerException();
|
||||
fCallable = callable;
|
||||
}
|
||||
|
||||
|
@ -256,6 +240,8 @@ public class DefaultDsfExecutor extends ScheduledThreadPoolExecutor
|
|||
traceExecution();
|
||||
|
||||
// Finally invoke the runnable code.
|
||||
// Note that callables can throw exceptions that can be caught
|
||||
// by clients that invoked them using ExecutionException.
|
||||
return fCallable.call();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ abstract public class AbstractDsfService
|
|||
/** Properties that this service was registered with */
|
||||
private String fFilter;
|
||||
|
||||
|
||||
/**
|
||||
* Only constructor, requires a reference to the session that this
|
||||
* service belongs to.
|
||||
|
|
|
@ -112,6 +112,8 @@ public class DsfServicesTracker {
|
|||
}
|
||||
} catch(InvalidSyntaxException e) {
|
||||
assert false : "Invalid session ID syntax"; //$NON-NLS-1$
|
||||
} catch(IllegalStateException e) {
|
||||
// Can occur when plugin is shutting down.
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -228,6 +228,8 @@ public class DsfSession
|
|||
/** Returns the owner ID of this session */
|
||||
public String getOwnerId() { return fOwnerId; }
|
||||
|
||||
public boolean isActive() { return DsfSession.isSessionActive(fId); }
|
||||
|
||||
/** Returns the ID of this session */
|
||||
public String getId() { return fId; }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue