void copy(InputStream from, OutputStream to, boolean buffer, boolean terminateOnFailure) throws IOException { if (buffer) { from = new BufferedInputStream(from); to = new BufferedOutputStream(to); } while (true) { int i; try { i = from.read(); if (i == END_OF_STREAM) { break; } to.write(i); } catch (Exception e) { if (terminateOnFailure) { break; } if (e instanceof IOException) { throw (IOException) e; } throw exceptions.toRuntime(e); } } to.flush(); }
void copy(InputStream from, OutputStream to, boolean buffer, boolean terminateOnFailure) throws IOException { if (buffer) { from = new BufferedInputStream(from); to = new BufferedOutputStream(to); } while (true) { int i; try { i = from.read(); if (i == END_OF_STREAM) { break; } to.write(i); } catch (Exception e) { if (terminateOnFailure) { break; } if (e instanceof IOException) { throw (IOException) e; } throw exceptions.toRuntime(e); } } to.flush(); }
void copy(InputStream from, OutputStream to, boolean buffer, boolean terminateOnFailure) throws IOException { if (buffer) { from = new BufferedInputStream(from); to = new BufferedOutputStream(to); } while (true) { int i; try { i = from.read(); if (i == END_OF_STREAM) { break; } to.write(i); } catch (Exception e) { if (terminateOnFailure) { break; } if (e instanceof IOException) { throw (IOException) e; } throw exceptions.toRuntime(e); } } to.flush(); }
public void testToRuntime() { Exception runtime = new RuntimeException("test"); assertSame(runtime, exceptions.toRuntime(runtime)); Exception checkedException = new SQLException("test"); assertFalse(checkedException instanceof RuntimeException); Exception returned = exceptions.toRuntime(checkedException); assertTrue(returned instanceof RuntimeException); assertEquals(checkedException, returned.getCause()); }
public void testToRuntime() { Exception runtime = new RuntimeException("test"); assertSame(runtime, exceptions.toRuntime(runtime)); Exception checkedException = new SQLException("test"); assertFalse(checkedException instanceof RuntimeException); Exception returned = exceptions.toRuntime(checkedException); assertTrue(returned instanceof RuntimeException); assertEquals(checkedException, returned.getCause()); }
public void testToRuntime() { Exception runtime = new RuntimeException("test"); assertSame(runtime, exceptions.toRuntime(runtime)); Exception checkedException = new SQLException("test"); assertFalse(checkedException instanceof RuntimeException); Exception returned = exceptions.toRuntime(checkedException); assertTrue(returned instanceof RuntimeException); assertEquals(checkedException, returned.getCause()); }
public void run() { if (p != null) { throw new IllegalStateException("Process already running"); } try { returnCode = null; p = runtime.exec(args, envp, workingDir); captureStdOutAndStdErr(); returnCode = new Integer(p.waitFor()); } catch (Exception e) { throw exceptions.toRuntime(e); } finally { // p.destroy(); p = null; for (int i = 0; i < listeners.size(); i++) { new Thread((Runnable) listeners.get(i)).start(); } listeners.clear(); } }
public void run() { if (p != null) { throw new IllegalStateException("Process already running"); } try { returnCode = null; p = runtime.exec(args, envp, workingDir); captureStdOutAndStdErr(); returnCode = new Integer(p.waitFor()); } catch (Exception e) { throw exceptions.toRuntime(e); } finally { // p.destroy(); p = null; for (int i = 0; i < listeners.size(); i++) { new Thread((Runnable) listeners.get(i)).start(); } listeners.clear(); } }
@Override public void run() { if (p != null) { throw new IllegalStateException("Process already running"); } try { returnCode = null; p = runtime.exec(args, envp, workingDir); captureStdOutAndStdErr(); returnCode = Integer.valueOf(p.waitFor()); } catch (Exception e) { throw exceptions.toRuntime(e); } finally { // p.destroy(); p = null; for (int i = 0; i < listeners.size(); i++) { new Thread((Runnable) listeners.get(i)).start(); } listeners.clear(); } }
public void assertNotImplemented(Object stub, Method method) { try { invoke(stub, method); } catch (NotImplementedException e) { return; } catch (Exception e) { if (isNotImplementedMsg(e.getMessage())) { return; } Throwable cause = e.getCause(); if (cause instanceof NotImplementedException) { return; } if (cause != null) { if (isNotImplementedMsg(cause.getMessage())) { return; } } new Exceptions().toRuntime(e); } throw new RuntimeException("This is now implemented."); }