public void close() { Safe.close(context); } }
public void close() { if (closed.compareAndSet(false, true)) { for (Closeable closeable : closeables) { log.log(Level.FINE, "Closing " + closeable.getClass().getSimpleName()); Safe.close(closeable); } } } }
public static void copy(InputStream in, OutputStream out) throws IOException { if (in == null) { throw new NullPointerException(); } try { byte[] buffer = new byte[256]; for (int l = in.read(buffer); l != -1; l = in.read(buffer)) { out.write(buffer, 0, l); } } finally { Safe.close(in); } }
@Override ShellResponse doInvoke(final ShellProcessContext context) throws InterruptedException { CRaSHProcessContext invocationContext = new CRaSHProcessContext(CRaSHSession.this, context); try { pipeLine.open(invocationContext); pipeLine.flush(); return ShellResponse.ok(); } catch (ScriptException e) { return build(e); } catch (Throwable t) { return build(t); } finally { Safe.close(pipeLine); Safe.close(invocationContext); } }
Safe.close(container);
Object dispatch(String methodName, Object[] arguments) { PipeCommandProxy pipe = resolvePipe(methodName, arguments, false); // try { pipe.fire(); return null; } catch (ScriptException e) { Throwable cause = e.getCause(); if (cause != null) { throw new InvokerInvocationException(cause); } else { throw e; } } finally { Safe.close(pipe); } }
Safe.close(closeable);