提交 effb12d5 编写于 作者: M michaelm

7058832: com/sun/net/httpserver/bugs/B6373555.java failing intermittently

Reviewed-by: alanb
上级 80f861d6
...@@ -43,14 +43,12 @@ public class B6373555 { ...@@ -43,14 +43,12 @@ public class B6373555 {
private static int port; private static int port;
private static volatile boolean error = false; private static volatile boolean error = false;
private static Object lock;
static HttpServer httpServer; static HttpServer httpServer;
static ExecutorService pool, execs; static ExecutorService pool, execs;
static int NUM = 1000; static int NUM = 1000;
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
try { try {
lock = new Object();
if (args.length > 0) { if (args.length > 0) {
NUM = Integer.parseInt (args[0]); NUM = Integer.parseInt (args[0]);
} }
...@@ -117,12 +115,6 @@ public class B6373555 { ...@@ -117,12 +115,6 @@ public class B6373555 {
System.out.println("Doesn't match"); System.out.println("Doesn't match");
error = true; error = true;
} }
synchronized(lock) {
++received;
if ((received % 1000) == 0) {
System.out.println("Received="+received);
}
}
} }
catch(Exception e) { catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
...@@ -150,18 +142,12 @@ public class B6373555 { ...@@ -150,18 +142,12 @@ public class B6373555 {
private static HttpServer createHttpServer(ExecutorService execs) private static HttpServer createHttpServer(ExecutorService execs)
throws Exception { throws Exception {
InetSocketAddress inetAddress = new InetSocketAddress(0); InetSocketAddress inetAddress = new InetSocketAddress(0);
HttpServer testServer = HttpServer.create(inetAddress, 5); HttpServer testServer = HttpServer.create(inetAddress, 15);
testServer.setExecutor(execs); testServer.setExecutor(execs);
HttpContext context = testServer.createContext("/test"); HttpContext context = testServer.createContext("/test");
context.setHandler(new HttpHandler() { context.setHandler(new HttpHandler() {
public void handle(HttpExchange msg) { public void handle(HttpExchange msg) {
try { try {
synchronized(lock) {
++s_received;
if ((s_received % 1000) == 0) {
System.out.println("Received="+s_received);
}
}
String method = msg.getRequestMethod(); String method = msg.getRequestMethod();
if (method.equals("POST")) { if (method.equals("POST")) {
InputStream is = msg.getRequestBody(); InputStream is = msg.getRequestBody();
...@@ -172,12 +158,6 @@ public class B6373555 { ...@@ -172,12 +158,6 @@ public class B6373555 {
System.out.println("****** METHOD not handled ***** "+method); System.out.println("****** METHOD not handled ***** "+method);
System.out.println("Received="+s_received); System.out.println("Received="+s_received);
} }
synchronized(lock) {
++sent;
if ((sent % 1000) == 0) {
System.out.println("sent="+sent);
}
}
} }
catch(Exception e) { catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册