Commit a9119caf authored by Kristof Szabados's avatar Kristof Szabados
Browse files

remove stream based console output handling.


It is unsafe to use in multi-threaded systems, as it grabs onto the the stream for a long time, possibly creating deadlocks.
Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent b12dda08
......@@ -47,7 +47,6 @@ import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.console.MessageConsoleStream;
import org.eclipse.ui.progress.IProgressConstants;
/**
......@@ -131,8 +130,6 @@ public final class RemoteBuilder extends AbstractHandler implements IObjectActio
Process proc = null;
BufferedReader stdout;
final MessageConsoleStream stream = TITANConsole.getConsole().newMessageStream();
String actualCommand;
for (int i = 0; i < commands.size(); i++) {
actualCommand = commands.get(i);
......@@ -148,13 +145,13 @@ public final class RemoteBuilder extends AbstractHandler implements IObjectActio
for (final String c : finalCommand) {
builder.append(c + ' ');
}
TITANConsole.println(builder.toString(),stream);
TITANConsole.println(builder.toString());
pb.command(finalCommand);
try {
proc = pb.start();
} catch (IOException e) {
TITANConsole.println(ExternalTitanAction.EXECUTION_FAILED,stream);
TITANConsole.println(ExternalTitanAction.EXECUTION_FAILED);
ErrorReporter.logExceptionStackTrace(e);
TITANJob.reportExecutionProblem(project, Platform.getPreferencesService(), getName(), finalCommand, null, false);
internalMonitor.done();
......@@ -173,15 +170,15 @@ public final class RemoteBuilder extends AbstractHandler implements IObjectActio
MarkerHandler.removeAllMarkedMarkers(project);
return Status.CANCEL_STATUS;
}
TITANConsole.println(hostnames.get(i) + ": " + line,stream);
TITANConsole.println(hostnames.get(i) + ": " + line);
line = stdout.readLine();
}
final int exitval = proc.waitFor();
if (exitval == 0) {
TITANConsole.println("The process on " + hostnames.get(i) + " finished without indicating an error.",stream);
TITANConsole.println("The process on " + hostnames.get(i) + " finished without indicating an error.");
} else {
TITANConsole.println(hostnames.get(i) + " finished with return value: " + exitval,stream);
TITANConsole.println(hostnames.get(i) + " finished with return value: " + exitval);
if (stderr.ready()) {
final StringBuilder builder2 = new StringBuilder();
......@@ -199,10 +196,10 @@ public final class RemoteBuilder extends AbstractHandler implements IObjectActio
return Status.CANCEL_STATUS;
}
} catch (IOException e) {
TITANConsole.println(ExternalTitanAction.EXECUTION_FAILED,stream);
TITANConsole.println(ExternalTitanAction.EXECUTION_FAILED);
ErrorReporter.logExceptionStackTrace(e);
} catch (InterruptedException e) {
TITANConsole.println(ExternalTitanAction.INTERRUPTION,stream);
TITANConsole.println(ExternalTitanAction.INTERRUPTION);
ErrorReporter.logExceptionStackTrace(e);
} finally {
try {
......
......@@ -45,7 +45,6 @@ import org.eclipse.titan.designer.license.License;
import org.eclipse.titan.designer.license.LicenseValidator;
import org.eclipse.titan.designer.preferences.PreferenceConstants;
import org.eclipse.titan.designer.productUtilities.ProductConstants;
import org.eclipse.ui.console.MessageConsoleStream;
import org.eclipse.ui.progress.IProgressConstants;
/**
......@@ -239,8 +238,6 @@ public class TITANJob extends WorkspaceJob {
pb.redirectErrorStream(true);
Process proc = null;
final MessageConsoleStream stream = TITANConsole.getConsole().newMessageStream();
String line;
BufferedReader stdout;
......@@ -289,13 +286,13 @@ public class TITANJob extends WorkspaceJob {
for (final String c : finalCommand) {
builder.append(c + SPACE);
}
TITANConsole.println(builder.toString(),stream);
TITANConsole.println(builder.toString());
pb.command(finalCommand);
try {
proc = pb.start();
} catch (IOException e) {
TITANConsole.println(ExternalTitanAction.EXECUTION_FAILED,stream);
TITANConsole.println(ExternalTitanAction.EXECUTION_FAILED);
ErrorReporter.logExceptionStackTrace(e);
reportExecutionProblem(project, prefs, getName(), finalCommand, null, false);
foundErrors = true;
......@@ -322,7 +319,7 @@ public class TITANJob extends WorkspaceJob {
return Status.CANCEL_STATUS;
}
analyzer.parseTitanErrors(line);
TITANConsole.println(line,stream);
TITANConsole.println(line);
}
int exitval = proc.waitFor();
......@@ -332,7 +329,7 @@ public class TITANJob extends WorkspaceJob {
}
if (exitval != 0) {
TITANConsole.println(FAILURE + exitval,stream);
TITANConsole.println(FAILURE + exitval);
if (!analyzer.hasProcessedErrorMessages()) {
if (stderr.ready()) {
final StringBuilder builder2 = new StringBuilder();
......@@ -353,12 +350,12 @@ public class TITANJob extends WorkspaceJob {
return Status.CANCEL_STATUS;
}
TITANConsole.println(SUCCESS,stream);
TITANConsole.println(SUCCESS);
} catch (IOException e) {
TITANConsole.println(ExternalTitanAction.EXECUTION_FAILED,stream);
TITANConsole.println(ExternalTitanAction.EXECUTION_FAILED);
ErrorReporter.logExceptionStackTrace(ExternalTitanAction.EXECUTION_FAILED, e);
} catch (InterruptedException e) {
TITANConsole.println(ExternalTitanAction.INTERRUPTION,stream);
TITANConsole.println(ExternalTitanAction.INTERRUPTION);
ErrorReporter.logExceptionStackTrace(ExternalTitanAction.INTERRUPTION, e);
} finally {
try {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment