mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8253368: TLS connection always receives close_notify exception
Reviewed-by: xuelei
This commit is contained in:
parent
4ea88512dd
commit
a4e082e985
2 changed files with 37 additions and 12 deletions
|
@ -820,18 +820,19 @@ public final class SSLSocketImpl
|
||||||
// Is it ready to close inbound?
|
// Is it ready to close inbound?
|
||||||
//
|
//
|
||||||
// No need to throw exception if the initial handshake is not started.
|
// No need to throw exception if the initial handshake is not started.
|
||||||
|
try {
|
||||||
if (checkCloseNotify && !conContext.isInputCloseNotified &&
|
if (checkCloseNotify && !conContext.isInputCloseNotified &&
|
||||||
(conContext.isNegotiated || conContext.handshakeContext != null)) {
|
(conContext.isNegotiated || conContext.handshakeContext != null)) {
|
||||||
|
throw new SSLException(
|
||||||
throw conContext.fatal(Alert.INTERNAL_ERROR,
|
|
||||||
"closing inbound before receiving peer's close_notify");
|
"closing inbound before receiving peer's close_notify");
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
conContext.closeInbound();
|
conContext.closeInbound();
|
||||||
if ((autoClose || !isLayered()) && !super.isInputShutdown()) {
|
if ((autoClose || !isLayered()) && !super.isInputShutdown()) {
|
||||||
super.shutdownInput();
|
super.shutdownInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isInputShutdown() {
|
public boolean isInputShutdown() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -23,9 +23,10 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8184328
|
* @bug 8184328 8253368
|
||||||
* @summary JDK8u131-b34-socketRead0 hang at SSL read
|
* @summary JDK8u131-b34-socketRead0 hang at SSL read
|
||||||
* @run main/othervm SSLSocketCloseHang
|
* @run main/othervm SSLSocketCloseHang
|
||||||
|
* @run main/othervm SSLSocketCloseHang shutdownInputTest
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -72,6 +73,8 @@ public class SSLSocketCloseHang {
|
||||||
*/
|
*/
|
||||||
static boolean debug = false;
|
static boolean debug = false;
|
||||||
|
|
||||||
|
static boolean shutdownInputTest = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the client or server is doing some kind of object creation
|
* If the client or server is doing some kind of object creation
|
||||||
* that the other side depends on, and that thread prematurely
|
* that the other side depends on, and that thread prematurely
|
||||||
|
@ -145,7 +148,26 @@ public class SSLSocketCloseHang {
|
||||||
Thread.sleep(500);
|
Thread.sleep(500);
|
||||||
System.err.println("Client closing: " + System.nanoTime());
|
System.err.println("Client closing: " + System.nanoTime());
|
||||||
|
|
||||||
|
if (shutdownInputTest) {
|
||||||
|
try {
|
||||||
|
sslSocket.shutdownInput();
|
||||||
|
} catch (SSLException e) {
|
||||||
|
if (!e.getMessage().contains
|
||||||
|
("closing inbound before receiving peer's close_notify")) {
|
||||||
|
throw new RuntimeException("expected different exception message. " +
|
||||||
|
e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!sslSocket.getSession().isValid()) {
|
||||||
|
throw new RuntimeException("expected session to remain valid");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
sslSocket.close();
|
sslSocket.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
clientClosed = true;
|
clientClosed = true;
|
||||||
System.err.println("Client closed: " + System.nanoTime());
|
System.err.println("Client closed: " + System.nanoTime());
|
||||||
}
|
}
|
||||||
|
@ -179,6 +201,8 @@ public class SSLSocketCloseHang {
|
||||||
if (debug)
|
if (debug)
|
||||||
System.setProperty("javax.net.debug", "all");
|
System.setProperty("javax.net.debug", "all");
|
||||||
|
|
||||||
|
shutdownInputTest = args.length > 0 ? true : false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start the tests.
|
* Start the tests.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue