List of usage examples for org.apache.commons.exec.util DebugUtils handleException
public static void handleException(final String msg, final Exception e)
From source file:com.example.gridtest.MyStreamPumper.java
/** * Copies data from the input stream to the output stream. Terminates as * soon as the input stream is closed or an error occurs. *///from w ww. j av a2 s .com public void run() { synchronized (this) { // Just in case this object is reused in the future finished = false; } final byte[] buf = new byte[this.size]; int length; try { while ((length = is.read(buf)) > 0) { os.write(buf, 0, length); os.flush(); // had to add this, because of this output stream is extremely slow, make two versions } } catch (Exception e) { // nothing to do - happens quite often with watchdog } finally { if (closeWhenExhausted) { try { os.close(); } catch (IOException e) { String msg = "Got exception while closing exhausted output stream"; DebugUtils.handleException(msg, e); } } synchronized (this) { finished = true; notifyAll(); } } }
From source file:com.example.gridtest.MyPumpStreamHandler.java
/** * Set the <CODE>OutputStream</CODE> by means of which input can be sent * to the process.//from ww w . j ava2s. c o m * * @param os * the <CODE>OutputStream</CODE>. */ public void setProcessInputStream(final OutputStream os) { if (input != null) { if (input == System.in) { inputThread = createSystemInPump(input, os); } else { inputThread = createPump(input, os, false); } } else { try { os.close(); } catch (IOException e) { String msg = "Got exception while closing output stream"; DebugUtils.handleException(msg, e); } } }
From source file:maker.task.compile.ReplTestPumpStreamHandler.java
/** * Set the <CODE>OutputStream</CODE> by means of which input can be sent * to the process.//from w w w . j a v a 2 s . c o m * * @param os the <CODE>OutputStream</CODE>. */ public void setProcessInputStream(final OutputStream os) { if (input != null) { //if (input == System.in) { inputThread = createSystemInPump(input, os); //} else { //inputThread = createPump(input, os, true); //} } else { try { os.close(); } catch (final IOException e) { final String msg = "Got exception while closing output stream"; DebugUtils.handleException(msg, e); } } }
From source file:com.example.gridtest.MyPumpStreamHandler.java
/** * Stop pumping the streams./*from ww w . j a v a 2 s . co m*/ */ public void stop() { if (inputStreamPumper != null) { inputStreamPumper.stopProcessing(); } if (outputThread != null) { try { outputThread.join(); outputThread = null; } catch (InterruptedException e) { // ignore } } if (errorThread != null) { try { errorThread.join(); errorThread = null; } catch (InterruptedException e) { // ignore } } if (inputThread != null) { try { inputThread.join(); inputThread = null; } catch (InterruptedException e) { // ignore } } if (err != null && err != out) { try { err.flush(); } catch (IOException e) { String msg = "Got exception while flushing the error stream : " + e.getMessage(); DebugUtils.handleException(msg, e); } } if (out != null) { try { out.flush(); } catch (IOException e) { String msg = "Got exception while flushing the output stream"; DebugUtils.handleException(msg, e); } } }
From source file:maker.task.compile.ReplTestPumpStreamHandler.java
/** * Stop pumping the streams. When a timeout is specified it it is not guaranteed that the * pumper threads are cleanly terminated. *//*w ww . j a v a 2 s. c om*/ public void stop() throws IOException { if (inputStreamPumper != null) { inputStreamPumper.stopProcessing(); } stopThread(outputThread, stopTimeout); stopThread(errorThread, stopTimeout); stopThread(inputThread, stopTimeout); if (err != null && err != out) { try { err.flush(); } catch (final IOException e) { final String msg = "Got exception while flushing the error stream : " + e.getMessage(); DebugUtils.handleException(msg, e); } } if (out != null) { try { out.flush(); } catch (final IOException e) { final String msg = "Got exception while flushing the output stream"; DebugUtils.handleException(msg, e); } } if (caught != null) { throw caught; } }
From source file:org.openflamingo.core.cmd.TailPumpStreamHandler.java
/** * Set the <CODE>OutputStream</CODE> by means of which input can be sent * to the process./*from w w w . ja v a 2 s .c om*/ * * @param os the <CODE>OutputStream</CODE>. */ public void setProcessInputStream(final OutputStream os) { if (input != null) { if (input == System.in) { inputThread = createSystemInPump(input, os); } else { inputThread = createPump(input, os, true); } } else { try { os.close(); } catch (IOException e) { String msg = "Got exception while closing output stream"; DebugUtils.handleException(msg, e); } } }
From source file:org.openflamingo.core.cmd.TailStreamPumper.java
/** * Copies data from the input stream to the output stream. Terminates as * soon as the input stream is closed or an error occurs. */// ww w. j av a2s . c o m public void run() { synchronized (this) { // Just in case this object is reused in the future finished = false; } final byte[] buf = new byte[this.size]; int length; try { while ((length = is.read(buf)) > 0) { os.write(buf, 0, length); } } catch (Exception e) { // nothing to do - happens quite often with watchdog } finally { if (closeWhenExhausted) { try { os.close(); } catch (IOException e) { String msg = "Got exception while closing exhausted output stream"; DebugUtils.handleException(msg, e); } } synchronized (this) { finished = true; notifyAll(); } } }