23 Star 19 Fork 75

src-openEuler / openjdk-1.8.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
8260923-Add-more-tests-for-SSLSocket-input-output-sh.patch 4.81 KB
一键复制 编辑 原始数据 按行查看 历史
kuen 提交于 2024-01-18 15:17 . I8X6CH: upgrade to 8u402
From c3aae68d629a3adc02fb0764c95d922e716f0ee3 Mon Sep 17 00:00:00 2001
From: zhangyipeng <zhangyipeng7@huawei.com>
Date: Mon, 15 Jan 2024 11:13:55 +0800
Subject: [PATCH] [Backport]8260923: Add more tests for SSLSocket input/output shutdown
---
.../ssl/SSLSocketImpl/SSLSocketCloseHang.java | 69 ++++++++++++++--------
1 file changed, 46 insertions(+), 23 deletions(-)
diff --git a/jdk/test/sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java b/jdk/test/sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java
index f74c1fe76..ff6334feb 100644
--- a/jdk/test/sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java
+++ b/jdk/test/sun/security/ssl/SSLSocketImpl/SSLSocketCloseHang.java
@@ -23,12 +23,17 @@
/*
* @test
- * @bug 8184328 8253368
+ * @bug 8184328 8253368 8260923
* @summary JDK8u131-b34-socketRead0 hang at SSL read
- * @run main/othervm SSLSocketCloseHang
- * @run main/othervm SSLSocketCloseHang shutdownInputTest
+ * @run main/othervm SSLSocketCloseHang TLSv1.2
+ * @run main/othervm SSLSocketCloseHang TLSv1.2 shutdownInput
+ * @run main/othervm SSLSocketCloseHang TLSv1.2 shutdownOutput
+ * @run main/othervm SSLSocketCloseHang TLSv1.3
+ * @run main/othervm SSLSocketCloseHang TLSv1.3 shutdownInput
+ * @run main/othervm SSLSocketCloseHang TLSv1.3 shutdownOutput
*/
+
import java.io.*;
import java.net.*;
import java.util.*;
@@ -36,7 +41,6 @@ import java.security.*;
import javax.net.ssl.*;
public class SSLSocketCloseHang {
-
/*
* =============================================================
* Set the various variables needed for the tests, then
@@ -73,7 +77,7 @@ public class SSLSocketCloseHang {
*/
static boolean debug = false;
- static boolean shutdownInputTest = false;
+ static String socketCloseType;
/*
* If the client or server is doing some kind of object creation
@@ -148,28 +152,45 @@ public class SSLSocketCloseHang {
Thread.sleep(500);
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");
- }
+ closeConnection(sslSocket);
+
+ clientClosed = true;
+ System.err.println("Client closed: " + System.nanoTime());
+ }
+ private void closeConnection(SSLSocket sslSocket) throws IOException {
+ if ("shutdownInput".equals(socketCloseType)) {
+ shutdownInput(sslSocket);
+ // second call to shutdownInput() should just return,
+ // shouldn't throw any exception
+ sslSocket.shutdownInput();
+ // invoking shutdownOutput() just after shutdownInput()
+ sslSocket.shutdownOutput();
+ } else if ("shutdownOutput".equals(socketCloseType)) {
+ sslSocket.shutdownOutput();
+ // second call to shutdownInput() should just return,
+ // shouldn't throw any exception
+ sslSocket.shutdownOutput();
+ // invoking shutdownInput() just after shutdownOutput()
+ shutdownInput(sslSocket);
} else {
sslSocket.close();
}
+ }
-
-
- clientClosed = true;
- System.err.println("Client closed: " + System.nanoTime());
+ private void shutdownInput(SSLSocket sslSocket) throws IOException {
+ 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");
+ }
}
/*
@@ -197,11 +218,13 @@ public class SSLSocketCloseHang {
System.setProperty("javax.net.ssl.keyStorePassword", passwd);
System.setProperty("javax.net.ssl.trustStore", trustFilename);
System.setProperty("javax.net.ssl.trustStorePassword", passwd);
+ System.setProperty("jdk.tls.client.protocols", args[0]);
if (debug)
System.setProperty("javax.net.debug", "all");
- shutdownInputTest = args.length > 0 ? true : false;
+ socketCloseType = args.length > 1 ? args[1] : "";
+
/*
* Start the tests.
--
2.12.3
1
https://gitee.com/src-openeuler/openjdk-1.8.0.git
git@gitee.com:src-openeuler/openjdk-1.8.0.git
src-openeuler
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助