diff --git a/nailgun-examples/src/main/java/com/martiansoftware/nailgun/examples/Exit.java b/nailgun-examples/src/main/java/com/martiansoftware/nailgun/examples/Exit.java index b13027ca..c524d68f 100644 --- a/nailgun-examples/src/main/java/com/martiansoftware/nailgun/examples/Exit.java +++ b/nailgun-examples/src/main/java/com/martiansoftware/nailgun/examples/Exit.java @@ -27,7 +27,10 @@ public static void main (String[] args) { exitCode = Integer.parseInt(args[0]); } catch (Exception e) {} } + // Close stdout to test the exit code is returned properly + // even in such case + System.out.close(); System.exit(exitCode); } -} \ No newline at end of file +} diff --git a/nailgun-server/src/main/java/com/martiansoftware/nailgun/NGOutputStream.java b/nailgun-server/src/main/java/com/martiansoftware/nailgun/NGOutputStream.java index 591c2442..0b90e774 100644 --- a/nailgun-server/src/main/java/com/martiansoftware/nailgun/NGOutputStream.java +++ b/nailgun-server/src/main/java/com/martiansoftware/nailgun/NGOutputStream.java @@ -74,4 +74,14 @@ public void write(byte[] b, int offset, int len) throws IOException { } flush(); } + + /** + * @see java.io.OutputStream.close() + * + * Implement an empty close function, to allow the client to close + * the stdout and/or stderr, without this closing the connection + * socket to the client. + */ + public void close() { + } }