Skip to content

Commit

Permalink
Merge pull request #148 from phensley/ph-ui-thread-hang-fix
Browse files Browse the repository at this point in the history
Fix debug launch thread hang using modified denyska patch.
  • Loading branch information
cbeust committed May 22, 2015
2 parents d91aea5 + a85c11b commit 72a1aea
Showing 1 changed file with 39 additions and 32 deletions.
Expand Up @@ -338,10 +338,10 @@ private void stopUpdateJobs() {
}
}

public void startTestRunListening(IJavaProject project,
public void startTestRunListening(final IJavaProject project,
String subName,
int port,
ILaunch launch) {
final ILaunch launch) {
m_workingProject = project;

aboutToLaunch(subName);
Expand All @@ -350,39 +350,46 @@ public void startTestRunListening(IJavaProject project,
// stopTest();
// }
fTestRunnerClient = new EclipseTestRunnerClient();
IMessageSender messageMarshaller = LaunchUtil.useStringProtocol(launch.getLaunchConfiguration())
final IMessageSender messageMarshaller = LaunchUtil.useStringProtocol(launch.getLaunchConfiguration())
? new StringMessageSender("localhost", port)
: new SerializedMessageSender("localhost", port);

boolean isInitSuccess = false;
do {
try {
messageMarshaller.initReceiver();
isInitSuccess = true;
} catch (SocketTimeoutException e) {
TestNGPlugin.log(e);
}
} while (isInitSuccess == false && launch.isTerminated() == false);

if (isInitSuccess == true) {
newSuiteRunInfo(launch);

fTestRunnerClient.startListening(currentSuiteRunInfo, currentSuiteRunInfo, messageMarshaller);
m_rerunAction.setEnabled(true);
m_rerunFailedAction.setEnabled(false);
m_openReportAction.setEnabled(true);
} else {
boolean useProjectJar =
TestNGPlugin.getPluginPreferenceStore().getUseProjectJar(project.getProject().getName());
String suggestion = useProjectJar
? "Uncheck the 'Use Project testng.jar' option from your Project properties and try again."
: "Make sure you don't have an older version of testng.jar on your class path.";
new ErrorDialog(m_counterComposite.getShell(), "Couldn't launch TestNG",
"Couldn't contact the RemoteTestNG client. " + suggestion,
new StatusInfo(IStatus.ERROR, "Timeout while trying to contact RemoteTestNG."),
IStatus.ERROR).open();
}
// getViewSite().getActionBars().updateActionBars();
String jobName = ResourceUtil.getString("TestRunnerViewPart.message.startTestRunListening");
Job testRunListeningJob = new Job(jobName) {
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
messageMarshaller.initReceiver();
newSuiteRunInfo(launch);
fTestRunnerClient.startListening(currentSuiteRunInfo, currentSuiteRunInfo, messageMarshaller);

postSyncRunnable(new Runnable() {
public void run() {
m_rerunAction.setEnabled(true);
m_rerunFailedAction.setEnabled(false);
m_openReportAction.setEnabled(true);
}
});
}
catch(SocketTimeoutException ex) {
postSyncRunnable(new Runnable() {
public void run() {
boolean useProjectJar =
TestNGPlugin.getPluginPreferenceStore().getUseProjectJar(project.getProject().getName());
String suggestion = useProjectJar
? "Uncheck the 'Use Project testng.jar' option from your Project properties and try again."
: "Make sure you don't have an older version of testng.jar on your class path.";
new ErrorDialog(m_counterComposite.getShell(), "Couldn't launch TestNG",
"Couldn't contact the RemoteTestNG client. " + suggestion,
new StatusInfo(IStatus.ERROR, "Timeout while trying to contact RemoteTestNG."),
IStatus.ERROR).open();
}
});
}
return Status.OK_STATUS;
}
};
testRunListeningJob.schedule();
}

/**
Expand Down

0 comments on commit 72a1aea

Please sign in to comment.