package jalview.bin;
import jalview.gui.JvOptionPane;
+import jalview.ws.utils.Worker;
import java.io.BufferedReader;
import java.io.File;
private ArrayList<String> successfulCMDs = new ArrayList<>();
- /***
- * from
- * http://stackoverflow.com/questions/808276/how-to-add-a-timeout-value-when
- * -using-javas-runtime-exec
- *
- * @author jimp
- *
- */
- private static class Worker extends Thread
- {
- private final Process process;
-
- private BufferedReader outputReader;
-
- private BufferedReader errorReader;
-
- private Integer exit;
-
- private Worker(Process process)
- {
- this.process = process;
- }
-
- @Override
- public void run()
- {
- try
- {
- exit = process.waitFor();
- } catch (InterruptedException ignore)
- {
- return;
- }
- }
-
- public BufferedReader getOutputReader()
- {
- return outputReader;
- }
-
- public void setOutputReader(BufferedReader outputReader)
- {
- this.outputReader = outputReader;
- }
-
- public BufferedReader getErrorReader()
- {
- return errorReader;
- }
-
- public void setErrorReader(BufferedReader errorReader)
- {
- this.errorReader = errorReader;
- }
- }
-
private Worker jalviewDesktopRunner(boolean withAwt, String cmd,
int timeout)
{
break;
}
}
- if (worker != null && worker.exit == null)
+ if (worker != null && worker.getExitValue() == null)
{
- worker.interrupt();
- Thread.currentThread().interrupt();
- worker.process.destroy();
+ worker.destroyProcess();
+
}
}
FileAssert.assertFile(file, "Didn't create an output" + type
+ " file.[" + harg + "]");
FileAssert.assertMinLength(new File(fileName), expectedMinFileSize);
- if (worker != null && worker.exit == null)
+ if (worker != null && worker.getExitValue() == null)
{
- worker.interrupt();
- Thread.currentThread().interrupt();
- worker.process.destroy();
+ worker.destroyProcess();
Assert.fail("Jalview did not exit after "
+ type
+ " generation (try running test again to verify - timeout at "