< prev index next >
test/jdk/java/net/httpclient/LightWeightHttpServer.java
Print this page
@@ -78,11 +78,11 @@
ConsoleHandler ch = new ConsoleHandler();
logger.setLevel(Level.ALL);
ch.setLevel(Level.ALL);
logger.addHandler(ch);
- String root = System.getProperty("test.src") + "/docs";
+ String root = System.getProperty("test.src", ".") + "/docs";
InetSocketAddress addr = new InetSocketAddress(0);
httpServer = HttpServer.create(addr, 0);
if (httpServer instanceof HttpsServer) {
throw new RuntimeException("should not be httpsserver");
}
@@ -299,15 +299,16 @@
return bar2;
}
@Override
public synchronized void handle(HttpExchange he) throws IOException {
- byte[] buf = Util.readAll(he.getRequestBody());
- try {
+ try(InputStream is = he.getRequestBody()) {
+ is.readAllBytes();
bar1.await();
bar2.await();
} catch (InterruptedException | BrokenBarrierException e) {
+ throw new IOException(e);
}
he.sendResponseHeaders(200, -1); // will probably fail
he.close();
}
}
< prev index next >