|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2017, 2020, 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 | /*
|
25 | 25 | * @test
|
26 |
| - * @bug 8184328 |
| 26 | + * @bug 8184328 8253368 |
27 | 27 | * @summary JDK8u131-b34-socketRead0 hang at SSL read
|
28 | 28 | * @run main/othervm SSLSocketCloseHang
|
| 29 | + * @run main/othervm SSLSocketCloseHang shutdownInputTest |
29 | 30 | */
|
30 | 31 |
|
31 | 32 | import java.io.*;
|
@@ -72,6 +73,8 @@ public class SSLSocketCloseHang {
|
72 | 73 | */
|
73 | 74 | static boolean debug = false;
|
74 | 75 |
|
| 76 | + static boolean shutdownInputTest = false; |
| 77 | + |
75 | 78 | /*
|
76 | 79 | * If the client or server is doing some kind of object creation
|
77 | 80 | * that the other side depends on, and that thread prematurely
|
@@ -145,7 +148,26 @@ void doClientSide() throws Exception {
|
145 | 148 | Thread.sleep(500);
|
146 | 149 | System.err.println("Client closing: " + System.nanoTime());
|
147 | 150 |
|
148 |
| - sslSocket.close(); |
| 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 | + } |
| 164 | + |
| 165 | + } else { |
| 166 | + sslSocket.close(); |
| 167 | + } |
| 168 | + |
| 169 | + |
| 170 | + |
149 | 171 | clientClosed = true;
|
150 | 172 | System.err.println("Client closed: " + System.nanoTime());
|
151 | 173 | }
|
@@ -179,6 +201,8 @@ public static void main(String[] args) throws Exception {
|
179 | 201 | if (debug)
|
180 | 202 | System.setProperty("javax.net.debug", "all");
|
181 | 203 |
|
| 204 | + shutdownInputTest = args.length > 0 ? true : false; |
| 205 | + |
182 | 206 | /*
|
183 | 207 | * Start the tests.
|
184 | 208 | */
|
|
0 commit comments