error.printStackTrace(); // RKV: NOPMD: Applet output
}
}
+
+ /**
+ * The class that reads output of the process passed in constructor in a separate thread.
+ * (a quick fix to the problem that we need to read bash script
+ * output in order for it to proceed correctly).
+ */
+ class ScriptOutputReader implements Runnable {
+
+ /**
+ * A quick fix to the problem that we need to read bash script output in order for it to proceed correctly.
+ */
+ Process _proc;
+
+ /**
+ * Constructor from process to take output from.
+ * @param proc
+ * the process to read from.
+ */
+ public ScriptOutputReader(final Process proc) {
+ _proc = proc;
+ }
+
+ /**
+ * {@inheritDoc}
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ try {
+ BufferedReader bri = new BufferedReader(new InputStreamReader(
+ _proc.getInputStream()));
+ BufferedReader bre = new BufferedReader(new InputStreamReader(
+ _proc.getErrorStream()));
+ String line = bri.readLine();
+ while (line != null) {
+ System.out.println(line); // RKV: NOPMD: Applet output
+ line = bri.readLine();
+ }
+ bri.close();
+ line = bre.readLine();
+ while (line != null) {
+ System.err.println(line); // RKV: NOPMD: Applet output
+ line = bre.readLine();
+ }
+ bre.close();
+ } catch(Exception e) {
+ // NOPMD: empty catch block - nothing really to do here.
+ }
+ }
+ }
/**
* Checkout a scenario and start Salome with it.
cmd.toArray(new String[] {}), null,
new File(SALOME_HOME));
- BufferedReader bri = new BufferedReader(new InputStreamReader(
- proc.getInputStream()));
- BufferedReader bre = new BufferedReader(new InputStreamReader(
- proc.getErrorStream()));
- String line = bri.readLine();
- while (line != null) {
- System.out.println(line); // RKV: NOPMD: Applet output
- line = bri.readLine();
- }
- bri.close();
- line = bre.readLine();
- while (line != null) {
- System.err.println(line); // RKV: NOPMD: Applet output
- line = bre.readLine();
- }
- bre.close();
+ // Read script's output in separate thread.
+ ScriptOutputReader appletOutputReader = new ScriptOutputReader(proc);
+ Thread thread = new Thread(appletOutputReader);
+ thread.start();
} else {
// Checkout of the scenario is failed at the beginning.
if (response != null) {