mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 07:14:30 +02:00
8216326: SSLSocket stream close() does not close the associated socket
Reviewed-by: jnimeh
This commit is contained in:
parent
781fb29580
commit
eb59ebb177
3 changed files with 166 additions and 2 deletions
|
@ -980,7 +980,7 @@ public final class SSLSocketImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shutdownInput(false);
|
SSLSocketImpl.this.close();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
// ignore the exception
|
// ignore the exception
|
||||||
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
|
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
|
||||||
|
@ -1146,7 +1146,7 @@ public final class SSLSocketImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
shutdownOutput();
|
SSLSocketImpl.this.close();
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
// ignore the exception
|
// ignore the exception
|
||||||
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
|
if (SSLLogger.isOn && SSLLogger.isOn("ssl")) {
|
||||||
|
|
82
test/jdk/javax/net/ssl/SSLSocket/InputStreamClosure.java
Normal file
82
test/jdk/javax/net/ssl/SSLSocket/InputStreamClosure.java
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// Please run in othervm mode. SunJSSE does not support dynamic system
|
||||||
|
// properties, no way to re-use system properties in samevm/agentvm mode.
|
||||||
|
//
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8216326
|
||||||
|
* @modules jdk.crypto.ec
|
||||||
|
* @library /javax/net/ssl/templates
|
||||||
|
* @summary SSLSocket stream close() does not close the associated socket
|
||||||
|
* @run main/othervm InputStreamClosure
|
||||||
|
*/
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import javax.net.ssl.SSLSocket;
|
||||||
|
|
||||||
|
public class InputStreamClosure extends SSLSocketTemplate {
|
||||||
|
|
||||||
|
// Run the test case.
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
(new InputStreamClosure()).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void runServerApplication(SSLSocket socket) throws Exception {
|
||||||
|
// here comes the test logic
|
||||||
|
InputStream sslIS = socket.getInputStream();
|
||||||
|
OutputStream sslOS = socket.getOutputStream();
|
||||||
|
|
||||||
|
sslIS.read();
|
||||||
|
sslOS.write(85);
|
||||||
|
sslOS.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define the client side application of the test for the specified socket.
|
||||||
|
* This method is used if the returned value of
|
||||||
|
* isCustomizedClientConnection() is false.
|
||||||
|
*
|
||||||
|
* @param socket may be null is no client socket is generated.
|
||||||
|
*
|
||||||
|
* @see #isCustomizedClientConnection()
|
||||||
|
*/
|
||||||
|
protected void runClientApplication(SSLSocket socket) throws Exception {
|
||||||
|
InputStream sslIS = socket.getInputStream();
|
||||||
|
OutputStream sslOS = socket.getOutputStream();
|
||||||
|
|
||||||
|
sslOS.write(280);
|
||||||
|
sslOS.flush();
|
||||||
|
sslIS.read();
|
||||||
|
|
||||||
|
sslIS.close();
|
||||||
|
if (!socket.isClosed()) {
|
||||||
|
throw new Exception("Closing the SSLSocket InputStream does " +
|
||||||
|
"not close the associated socket");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
82
test/jdk/javax/net/ssl/SSLSocket/OutputStreamClosure.java
Normal file
82
test/jdk/javax/net/ssl/SSLSocket/OutputStreamClosure.java
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//
|
||||||
|
// Please run in othervm mode. SunJSSE does not support dynamic system
|
||||||
|
// properties, no way to re-use system properties in samevm/agentvm mode.
|
||||||
|
//
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @test
|
||||||
|
* @bug 8216326
|
||||||
|
* @modules jdk.crypto.ec
|
||||||
|
* @library /javax/net/ssl/templates
|
||||||
|
* @summary SSLSocket stream close() does not close the associated socket
|
||||||
|
* @run main/othervm OutputStreamClosure
|
||||||
|
*/
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import javax.net.ssl.SSLSocket;
|
||||||
|
|
||||||
|
public class OutputStreamClosure extends SSLSocketTemplate {
|
||||||
|
|
||||||
|
// Run the test case.
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
(new OutputStreamClosure()).run();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void runServerApplication(SSLSocket socket) throws Exception {
|
||||||
|
// here comes the test logic
|
||||||
|
InputStream sslIS = socket.getInputStream();
|
||||||
|
OutputStream sslOS = socket.getOutputStream();
|
||||||
|
|
||||||
|
sslIS.read();
|
||||||
|
sslOS.write(85);
|
||||||
|
sslOS.flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Define the client side application of the test for the specified socket.
|
||||||
|
* This method is used if the returned value of
|
||||||
|
* isCustomizedClientConnection() is false.
|
||||||
|
*
|
||||||
|
* @param socket may be null is no client socket is generated.
|
||||||
|
*
|
||||||
|
* @see #isCustomizedClientConnection()
|
||||||
|
*/
|
||||||
|
protected void runClientApplication(SSLSocket socket) throws Exception {
|
||||||
|
InputStream sslIS = socket.getInputStream();
|
||||||
|
OutputStream sslOS = socket.getOutputStream();
|
||||||
|
|
||||||
|
sslOS.write(280);
|
||||||
|
sslOS.flush();
|
||||||
|
sslIS.read();
|
||||||
|
|
||||||
|
sslOS.close();
|
||||||
|
if (!socket.isClosed()) {
|
||||||
|
throw new Exception("Closing the SSLSocket OutputStream does " +
|
||||||
|
"not close the associated socket");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue