bug[ats_ATS326837]: Message Watch Recording not working in 0.23.1 There is a deadlock whenever one tries to send callback Events in the Main (GUI) thread. Solution is to send such events in a separate thread.
diff --git a/org.eclipse.ote.ui.message/src/org/eclipse/ote/ui/message/watch/WatchView.java b/org.eclipse.ote.ui.message/src/org/eclipse/ote/ui/message/watch/WatchView.java index 67e200b..de0f963 100644 --- a/org.eclipse.ote.ui.message/src/org/eclipse/ote/ui/message/watch/WatchView.java +++ b/org.eclipse.ote.ui.message/src/org/eclipse/ote/ui/message/watch/WatchView.java
@@ -17,6 +17,9 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Map; +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; import java.util.logging.Level; import org.eclipse.core.runtime.jobs.Job; import org.eclipse.jface.action.Action; @@ -168,6 +171,8 @@ private IOteMessageService messageService = null; private final SelectionListener recBtnHandler = new SelectionListener() { + + ExecutorService executor = Executors.newSingleThreadExecutor(); @Override public void widgetDefaultSelected(SelectionEvent e) { @@ -178,35 +183,58 @@ public void widgetSelected(SelectionEvent e) { if (recordButton.getSelection()) { - RecordingWizard recordingWizard = new RecordingWizard(watchList); + final RecordingWizard recordingWizard = new RecordingWizard(watchList); final WizardDialog recdialog = new WizardDialog(Displays.getActiveShell(), recordingWizard); int recResult = recdialog.open(); if (Window.OK == recResult) { - try { - saveWatchFile(); - messageService.startRecording(recordingWizard.getFileName(), - recordingWizard.getFilteredMessageRecordDetails()).addListener(recBtnListener); - } catch (FileNotFoundException ex) { - MessageDialog.openError(Displays.getActiveShell(), "Recording Error", - "Failed to open file for writing. " + "Make sure its not being used by another application"); - recordButton.setSelection(false); - } catch (Throwable ex) { - OseeLog.log(Activator.class, Level.SEVERE, "Failed to start message recording", ex); - MessageDialog.openError(Displays.getActiveShell(), "Recording Error", - "Exception ocurred while recording. see error log"); - recordButton.setSelection(false); - } + executor.submit(new Runnable() { + + @Override + public void run() { + try { + saveWatchFile(); + messageService.startRecording(recordingWizard.getFileName(), + recordingWizard.getFilteredMessageRecordDetails()).addListener(recBtnListener); + } catch (FileNotFoundException ex) { + Display.getCurrent().asyncExec(new Runnable() { + @Override + public void run() { + MessageDialog.openError(Displays.getActiveShell(), "Recording Error", + "Failed to open file for writing. " + "Make sure its not being used by another application"); + recordButton.setSelection(false); + } + }); + } catch (Throwable ex) { + OseeLog.log(Activator.class, Level.SEVERE, "Failed to start message recording", ex); + Display.getCurrent().asyncExec(new Runnable() { + + @Override + public void run() { + MessageDialog.openError(Displays.getActiveShell(), "Recording Error", + "Exception ocurred while recording. see error log"); + recordButton.setSelection(false); + } + }); + } + } + }); } else { recordButton.setSelection(false); } } else { - try { - messageService.stopRecording(); - } catch (IOException ioe) { - OseeLog.log(Activator.class, Level.WARNING, "problem when attempting to stop recording", ioe); - } catch (Throwable t) { - OseeLog.log(Activator.class, Level.SEVERE, "problem when attempting to stop recording", t); - } + executor.submit(new Runnable() { + + @Override + public void run() { + try { + messageService.stopRecording(); + } catch (IOException ioe) { + OseeLog.log(Activator.class, Level.WARNING, "problem when attempting to stop recording", ioe); + } catch (Throwable t) { + OseeLog.log(Activator.class, Level.SEVERE, "problem when attempting to stop recording", t); + } + } + }); } } };