|
1 | 1 | /* |
2 | | - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2010, 2026, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 | 4 | * |
5 | 5 | * This code is free software; you can redistribute it and/or modify it |
|
23 | 23 |
|
24 | 24 | import java.io.ByteArrayInputStream; |
25 | 25 | import java.io.EOFException; |
26 | | -import java.io.File; |
27 | | -import java.io.FileInputStream; |
28 | | -import java.io.FileNotFoundException; |
29 | 26 | import java.io.IOException; |
30 | 27 | import java.io.InputStream; |
31 | 28 | import java.io.OutputStream; |
|
37 | 34 | import java.security.Principal; |
38 | 35 | import java.security.PrivateKey; |
39 | 36 | import java.security.SecureRandom; |
40 | | -import java.security.UnrecoverableKeyException; |
41 | 37 | import java.security.cert.Certificate; |
42 | 38 | import java.security.cert.CertificateException; |
43 | 39 | import java.security.cert.CertificateFactory; |
@@ -196,6 +192,8 @@ public class CipherTestUtils { |
196 | 192 | static abstract class Server implements Runnable, AutoCloseable { |
197 | 193 |
|
198 | 194 | final CipherTestUtils cipherTest; |
| 195 | + // Thread that uses this server |
| 196 | + private volatile Thread serverThread; |
199 | 197 |
|
200 | 198 | Server(CipherTestUtils cipherTest) throws Exception { |
201 | 199 | this.cipherTest = cipherTest; |
@@ -238,6 +236,14 @@ void handleRequest(InputStream in, OutputStream out) |
238 | 236 | out.write(tp.toString().getBytes()); |
239 | 237 | out.write(" Test PASSED.".getBytes()); |
240 | 238 | } |
| 239 | + |
| 240 | + protected void setServerThread(final Thread serverThread) { |
| 241 | + this.serverThread = serverThread; |
| 242 | + } |
| 243 | + |
| 244 | + protected final Thread getServerThread() { |
| 245 | + return serverThread; |
| 246 | + } |
241 | 247 | } |
242 | 248 |
|
243 | 249 | public static class TestParameters { |
@@ -520,6 +526,7 @@ public static Server mainServer(PeerFactory peerFactory, |
520 | 526 | CipherTestUtils cipherTest = CipherTestUtils.getInstance(); |
521 | 527 | Server srv = peerFactory.newServer(cipherTest, PeerFactory.FREE_PORT); |
522 | 528 | Thread serverThread = new Thread(srv, "Server"); |
| 529 | + srv.setServerThread(serverThread); |
523 | 530 | serverThread.start(); |
524 | 531 |
|
525 | 532 | return srv; |
|
0 commit comments