1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

[292271] Guard against RejectedExecutionExceptions. Also, DsfServicesTracker.dispose() is now ThreadSafe so does not need to be called in the executor, which is good because we should still make this call even in the case of a RejectedExecution exception.

This commit is contained in:
Marc Khouzam 2009-10-15 20:17:34 +00:00
parent ee3801c51f
commit 06b3823732
2 changed files with 50 additions and 36 deletions

View file

@ -20,6 +20,7 @@ import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import org.eclipse.cdt.core.IAddress; import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.CDIDebugModel; import org.eclipse.cdt.debug.core.CDIDebugModel;
@ -2362,21 +2363,23 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
if (fTargetContext != null) { if (fTargetContext != null) {
if (fDebugSessionId != null) { if (fDebugSessionId != null) {
if (getSession() != null) { if (getSession() != null) {
// Store the values that we are going to change try {
final DsfSession session = getSession(); // Store the values that we are going to change
final DsfServicesTracker trackerToDispose= fServicesTracker; final DsfSession session = getSession();
session.getExecutor().execute(new DsfRunnable() { session.getExecutor().execute(new DsfRunnable() {
public void run() { public void run() {
session.removeServiceEventListener(DisassemblyPart.this); session.removeServiceEventListener(DisassemblyPart.this);
if (trackerToDispose != null) { }
trackerToDispose.dispose(); });
} } catch (RejectedExecutionException e) {
// Session is shut down.
} }
});
} }
} }
fDebugSessionId= sessionId; fDebugSessionId= sessionId;
if (fServicesTracker != null) {
fServicesTracker.dispose();
}
fServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), sessionId); fServicesTracker = new DsfServicesTracker(DsfUIPlugin.getBundleContext(), sessionId);
if (fViewer != null) { if (fViewer != null) {
debugContextChanged(); debugContextChanged();
@ -2397,22 +2400,24 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
} }
} else if (fDebugSessionId != null) { } else if (fDebugSessionId != null) {
if (getSession() != null) { if (getSession() != null) {
// Store the values that we are going to change try {
final DsfSession session = getSession(); // Store the values that we are going to change
final DsfServicesTracker trackerToDispose= fServicesTracker; final DsfSession session = getSession();
session.getExecutor().execute(new DsfRunnable() { session.getExecutor().execute(new DsfRunnable() {
public void run() { public void run() {
session.removeServiceEventListener(DisassemblyPart.this); session.removeServiceEventListener(DisassemblyPart.this);
if (trackerToDispose != null) { }
trackerToDispose.dispose(); });
} } catch (RejectedExecutionException e) {
// Session is shut down.
} }
});
} }
fDebugSessionId= null; fDebugSessionId= null;
fTargetContext= null; fTargetContext= null;
fServicesTracker= null; if (fServicesTracker != null) {
fServicesTracker.dispose();
fServicesTracker= null;
}
if (fViewer != null) { if (fViewer != null) {
debugContextChanged(); debugContextChanged();
} }
@ -2425,12 +2430,16 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem
fUpdatePending = false; fUpdatePending = false;
resetViewer(); resetViewer();
if (fDebugSessionId != null) { if (fDebugSessionId != null) {
final DsfSession session= getSession(); try {
session.getExecutor().execute(new DsfRunnable() { final DsfSession session= getSession();
public void run() { session.getExecutor().execute(new DsfRunnable() {
session.addServiceEventListener(DisassemblyPart.this, null); public void run() {
} session.addServiceEventListener(DisassemblyPart.this, null);
}); }
});
} catch (RejectedExecutionException e) {
// Session is shut down.
}
updatePC(PC_UNKNOWN); updatePC(PC_UNKNOWN);

View file

@ -618,11 +618,16 @@ public class DsfSourceDisplayAdapter implements ISourceDisplay, ISteppingControl
fController.removeSteppingControlParticipant(this); fController.removeSteppingControlParticipant(this);
fController = null; fController = null;
} }
fExecutor.execute(new DsfRunnable() { public void run() {
fSession.removeServiceEventListener(DsfSourceDisplayAdapter.this);
fServicesTracker.dispose();
}});
try {
fExecutor.execute(new DsfRunnable() { public void run() {
fSession.removeServiceEventListener(DsfSourceDisplayAdapter.this);
}});
} catch (RejectedExecutionException e) {
// Session is shut down.
}
fServicesTracker.dispose();
fSourceLookup.removeParticipants(new ISourceLookupParticipant[] {fSourceLookupParticipant}); fSourceLookup.removeParticipants(new ISourceLookupParticipant[] {fSourceLookupParticipant});
// fSourceLookupParticipant is disposed by the source lookup director // fSourceLookupParticipant is disposed by the source lookup director