|
23 | 23 |
|
24 | 24 | /*
|
25 | 25 | * @test
|
26 |
| - * @bug 8184328 8253368 |
| 26 | + * @bug 8184328 8253368 8260923 |
27 | 27 | * @summary JDK8u131-b34-socketRead0 hang at SSL read
|
28 |
| - * @run main/othervm SSLSocketCloseHang |
29 |
| - * @run main/othervm SSLSocketCloseHang shutdownInputTest |
| 28 | + * @run main/othervm SSLSocketCloseHang TLSv1.2 |
| 29 | + * @run main/othervm SSLSocketCloseHang TLSv1.2 shutdownInput |
| 30 | + * @run main/othervm SSLSocketCloseHang TLSv1.2 shutdownOutput |
| 31 | + * @run main/othervm SSLSocketCloseHang TLSv1.3 |
| 32 | + * @run main/othervm SSLSocketCloseHang TLSv1.3 shutdownInput |
| 33 | + * @run main/othervm SSLSocketCloseHang TLSv1.3 shutdownOutput |
30 | 34 | */
|
31 | 35 |
|
| 36 | + |
32 | 37 | import java.io.*;
|
33 | 38 | import java.net.*;
|
34 | 39 | import java.util.*;
|
35 | 40 | import java.security.*;
|
36 | 41 | import javax.net.ssl.*;
|
37 | 42 |
|
38 | 43 | public class SSLSocketCloseHang {
|
39 |
| - |
40 | 44 | /*
|
41 | 45 | * =============================================================
|
42 | 46 | * Set the various variables needed for the tests, then
|
@@ -73,7 +77,7 @@ public class SSLSocketCloseHang {
|
73 | 77 | */
|
74 | 78 | static boolean debug = false;
|
75 | 79 |
|
76 |
| - static boolean shutdownInputTest = false; |
| 80 | + static String socketCloseType; |
77 | 81 |
|
78 | 82 | /*
|
79 | 83 | * If the client or server is doing some kind of object creation
|
@@ -148,28 +152,45 @@ void doClientSide() throws Exception {
|
148 | 152 | Thread.sleep(500);
|
149 | 153 | System.err.println("Client closing: " + System.nanoTime());
|
150 | 154 |
|
151 |
| - if (shutdownInputTest) { |
152 |
| - try { |
153 |
| - sslSocket.shutdownInput(); |
154 |
| - } catch (SSLException e) { |
155 |
| - if (!e.getMessage().contains |
156 |
| - ("closing inbound before receiving peer's close_notify")) { |
157 |
| - throw new RuntimeException("expected different exception message. " + |
158 |
| - e.getMessage()); |
159 |
| - } |
160 |
| - } |
161 |
| - if (!sslSocket.getSession().isValid()) { |
162 |
| - throw new RuntimeException("expected session to remain valid"); |
163 |
| - } |
| 155 | + closeConnection(sslSocket); |
| 156 | + |
| 157 | + clientClosed = true; |
| 158 | + System.err.println("Client closed: " + System.nanoTime()); |
| 159 | + } |
164 | 160 |
|
| 161 | + private void closeConnection(SSLSocket sslSocket) throws IOException { |
| 162 | + if ("shutdownInput".equals(socketCloseType)) { |
| 163 | + shutdownInput(sslSocket); |
| 164 | + // second call to shutdownInput() should just return, |
| 165 | + // shouldn't throw any exception |
| 166 | + sslSocket.shutdownInput(); |
| 167 | + // invoking shutdownOutput() just after shutdownInput() |
| 168 | + sslSocket.shutdownOutput(); |
| 169 | + } else if ("shutdownOutput".equals(socketCloseType)) { |
| 170 | + sslSocket.shutdownOutput(); |
| 171 | + // second call to shutdownInput() should just return, |
| 172 | + // shouldn't throw any exception |
| 173 | + sslSocket.shutdownOutput(); |
| 174 | + // invoking shutdownInput() just after shutdownOutput() |
| 175 | + shutdownInput(sslSocket); |
165 | 176 | } else {
|
166 | 177 | sslSocket.close();
|
167 | 178 | }
|
| 179 | + } |
168 | 180 |
|
169 |
| - |
170 |
| - |
171 |
| - clientClosed = true; |
172 |
| - System.err.println("Client closed: " + System.nanoTime()); |
| 181 | + private void shutdownInput(SSLSocket sslSocket) throws IOException { |
| 182 | + try { |
| 183 | + sslSocket.shutdownInput(); |
| 184 | + } catch (SSLException e) { |
| 185 | + if (!e.getMessage().contains |
| 186 | + ("closing inbound before receiving peer's close_notify")) { |
| 187 | + throw new RuntimeException("expected different exception " |
| 188 | + + "message. " + e.getMessage()); |
| 189 | + } |
| 190 | + } |
| 191 | + if (!sslSocket.getSession().isValid()) { |
| 192 | + throw new RuntimeException("expected session to remain valid"); |
| 193 | + } |
173 | 194 | }
|
174 | 195 |
|
175 | 196 | /*
|
@@ -197,11 +218,13 @@ public static void main(String[] args) throws Exception {
|
197 | 218 | System.setProperty("javax.net.ssl.keyStorePassword", passwd);
|
198 | 219 | System.setProperty("javax.net.ssl.trustStore", trustFilename);
|
199 | 220 | System.setProperty("javax.net.ssl.trustStorePassword", passwd);
|
| 221 | + System.setProperty("jdk.tls.client.protocols", args[0]); |
200 | 222 |
|
201 | 223 | if (debug)
|
202 | 224 | System.setProperty("javax.net.debug", "all");
|
203 | 225 |
|
204 |
| - shutdownInputTest = args.length > 0 ? true : false; |
| 226 | + socketCloseType = args.length > 1 ? args[1] : ""; |
| 227 | + |
205 | 228 |
|
206 | 229 | /*
|
207 | 230 | * Start the tests.
|
|
0 commit comments