@Test public void testClose() throws IOException { var connection = new ProcessRpcConnection(process); connection.close(); verify(process, never()).destroy(); var closingConnection = new ProcessRpcConnection(process, true); closingConnection.close(); verify(process).destroy(); var newProcess = Mockito.mock(Process.class); try (var autoClosedConnection = new ProcessRpcConnection(newProcess, true)) { autoClosedConnection.getIncomingStream(); } verify(newProcess).destroy(); }
@Override public void close() throws IOException { log.info("Closing process connection. Killing process = {}", killProcessOnClose); if (killProcessOnClose) { process.destroy(); } }
ProcessRpcConnection implements RpcConnection { @Override public void close() throws IOException { log.info("Closing process connection. Killing process = {}", killProcessOnClose); if (killProcessOnClose) { process.destroy(); } } }
ProcessRpcConnection implements RpcConnection { @Override public void close() throws IOException { log.info("Closing process connection. Killing process = {}", killProcessOnClose); if (killProcessOnClose) { process.destroy(); } } ProcessRpcConnection(Process process);  ProcessRpcConnection(Process process, boolean killProcessOnClose); }
ProcessRpcConnection implements RpcConnection { @Override public void close() throws IOException { log.info("Closing process connection. Killing process = {}", killProcessOnClose); if (killProcessOnClose) { process.destroy(); } } ProcessRpcConnection(Process process);  ProcessRpcConnection(Process process, boolean killProcessOnClose); @Override InputStream getIncomingStream(); @Override OutputStream getOutgoingStream(); @Override void close(); @Override String toString(); }
ProcessRpcConnection implements RpcConnection { @Override public void close() throws IOException { log.info("Closing process connection. Killing process = {}", killProcessOnClose); if (killProcessOnClose) { process.destroy(); } } ProcessRpcConnection(Process process);  ProcessRpcConnection(Process process, boolean killProcessOnClose); @Override InputStream getIncomingStream(); @Override OutputStream getOutgoingStream(); @Override void close(); @Override String toString(); static final Logger log; }