Always close the output stream after a request has completed.
authorFredrik Tolf <fredrik@dolda2000.com>
Mon, 12 Oct 2009 20:33:19 +0000 (22:33 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Mon, 12 Oct 2009 20:33:19 +0000 (22:33 +0200)
src/dolda/jsvc/RequestThread.java
src/dolda/jsvc/test/TestResponder.java

index c6b9373..7940748 100644 (file)
@@ -12,6 +12,11 @@ public class RequestThread extends Thread {
     
     public void run() {
        resp.respond(req);
+       try {
+           req.output().close();
+       } catch(java.io.IOException e) {
+           throw(new RuntimeException(e));
+       }
     }
     
     public static Request request() {
index fb83ecb..1bf4f58 100644 (file)
@@ -12,16 +12,14 @@ public class TestResponder implements Responder {
        } catch(UnsupportedEncodingException e) {
            throw(new Error(e));
        }
-       try {
-           out.println("<html>");
-           out.println("<head><title>Barda</title></head>");
-           out.println("<body>");
-           out.println("<h1>Barda</h1>");
-           out.println("Bardslen.");
-           out.println("</body>");
-           out.println("</html>");
-       } finally {
-           out.close();
-       }
+
+       out.println("<html>");
+       out.println("<head><title>Barda</title></head>");
+       out.println("<body>");
+       out.println("<h1>Barda</h1>");
+       out.println("Bardslen.");
+       out.println("</body>");
+       out.println("</html>");
+       out.flush();
     }
 }