--- old/test/jdk/sun/net/www/http/HttpClient/MultiThreadTest.java 2018-09-25 09:47:54.000000000 +0100 +++ new/test/jdk/sun/net/www/http/HttpClient/MultiThreadTest.java 2018-09-25 09:47:54.000000000 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,8 @@ import java.net.*; import java.io.*; +import java.util.ArrayList; +import java.util.List; public class MultiThreadTest extends Thread { @@ -168,6 +170,7 @@ ServerSocket ss; int connectionCount; boolean shutdown = false; + List workers = new ArrayList<>(); Server(ServerSocket ss) { this.ss = ss; @@ -179,6 +182,8 @@ public synchronized void shutdown() { shutdown = true; + for (Worker worker : workers) + worker.stopWorker(); } public void run() { @@ -203,11 +208,13 @@ } int id; + Worker w; synchronized (this) { id = connectionCount++; + w = new Worker(s, id); + workers.add(w); } - Worker w = new Worker(s, id); w.start(); MultiThreadTest.debug("server: Started worker " + id); } @@ -229,12 +236,19 @@ class Worker extends Thread { Socket s; int id; + volatile boolean stopped; Worker(Socket s, int id) { this.s = s; this.id = id; } + void stopWorker() { + stopped = true; + try { s.close(); } + catch (IOException ignore) { } + } + static int requests = 0; static Object rlock = new Object(); @@ -313,7 +327,8 @@ } } catch (Exception e) { - e.printStackTrace(); + if (!stopped) + e.printStackTrace(); } finally { try { s.close();