Skip to content

Commit 6081d40

Browse files
committed
replace close() introduced in 19 by 8277090 but its implementation
1 parent 975200b commit 6081d40

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

test/jdk/com/sun/net/httpserver/Test12.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,24 @@ public static void main (String[] args) throws Exception {
110110
if (s2 != null) {
111111
s2.stop(0);
112112
}
113-
executor.close();
113+
boolean terminated = executor.isTerminated();
114+
if (!terminated) {
115+
executor.shutdown();
116+
boolean interrupted = false;
117+
while (!terminated) {
118+
try {
119+
terminated = executor.awaitTermination(1L, TimeUnit.DAYS);
120+
} catch (InterruptedException e) {
121+
if (!interrupted) {
122+
executor.shutdownNow();
123+
interrupted = true;
124+
}
125+
}
126+
}
127+
if (interrupted) {
128+
Thread.currentThread().interrupt();
129+
}
130+
}
114131
// it's OK to delete these files since the server side handlers
115132
// serving these files have completed (guaranteed by the completion of Executor.close())
116133
System.out.println("deleting " + smallFilePath);

0 commit comments

Comments
 (0)