public synchronized void end(ShellResponse response) { // It may have been cancelled concurrently if (client.current == this) { // Flush what we have in buffer first flush(); // Send end message try { client.current = null; client.out.writeObject(new ServerMessage.End(response)); client.out.flush(); } catch (IOException ignore) { // } finally { closed = true; if (response instanceof ShellResponse.Close) { client.close(); } } } } }
public synchronized void end(ShellResponse response) { // It may have been cancelled concurrently if (client.current == this) { // Flush what we have in buffer first flush(); // Send end message try { client.current = null; client.out.writeObject(new ServerMessage.End(response)); client.out.flush(); } catch (IOException ignore) { // } finally { closed = true; if (response instanceof ShellResponse.Close) { client.close(); } } } } }
public synchronized void end(ShellResponse response) { // It may have been cancelled concurrently if (client.current == this) { // Flush what we have in buffer first flush(); // Send end message try { client.current = null; client.out.writeObject(new ServerMessage.End(response)); client.out.flush(); } catch (IOException ignore) { // } finally { closed = true; if (response instanceof ShellResponse.Close) { client.close(); } } } } }
public synchronized void end(ShellResponse response) { // It may have been cancelled concurrently if (client.current == this) { // Flush what we have in buffer first flush(); // Send end message try { client.current = null; client.out.writeObject(new ServerMessage.End(response)); client.out.flush(); } catch (IOException ignore) { // } finally { closed = true; if (response instanceof ShellResponse.Close) { client.close(); } } } } }
public void testErrorResponseSerialiation() throws Exception { ShellResponse.Error expectedResponse = ShellResponse.error(ErrorKind.EVALUATION, "hell", new MyException()); ServerMessage expectedMessage = new ServerMessage.End(expectedResponse); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); oos.writeObject(expectedMessage); oos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); ObjectInputStream ois = new ObjectInputStream(bais); Object o = ois.readObject(); ServerMessage.End message = assertInstance(ServerMessage.End.class, o); ShellResponse.Error response = assertInstance(ShellResponse.Error.class, message.response); assertEquals(expectedResponse.getMessage(), response.getMessage()); assertEquals(Arrays.asList(expectedResponse.getThrowable().getStackTrace()), Arrays.asList(response.getThrowable().getStackTrace())); } }