1 Star 0 Fork 81

lyn/openjdk-1.8.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
8179273-sun.net.httpserver.LeftOverInputStream-shoul.patch 2.09 KB
一键复制 编辑 原始数据 按行查看 历史
wanghao 提交于 2023-08-01 15:30 . I7PICQ: upgrade to jdk8u382-ga
From b1c3eca9320e83db1fe6fe281c2d4a8875e8f16b Mon Sep 17 00:00:00 2001
Date: Thu, 27 Jul 2023 20:07:00 +0800
Subject: [PATCH] [Backport]8179273: sun.net.httpserver.LeftOverInputStream should stop
attempting to drain the stream when the server is stopped
---
.../classes/sun/net/httpserver/LeftOverInputStream.java | 7 +++++--
jdk/src/share/classes/sun/net/httpserver/ServerImpl.java | 4 ++++
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/jdk/src/share/classes/sun/net/httpserver/LeftOverInputStream.java b/jdk/src/share/classes/sun/net/httpserver/LeftOverInputStream.java
index c715d72ad..d3a6e1b08 100644
--- a/jdk/src/share/classes/sun/net/httpserver/LeftOverInputStream.java
+++ b/jdk/src/share/classes/sun/net/httpserver/LeftOverInputStream.java
@@ -41,8 +41,8 @@ import com.sun.net.httpserver.spi.*;
* isEOF() returns true, when all expected bytes have been read
*/
abstract class LeftOverInputStream extends FilterInputStream {
- ExchangeImpl t;
- ServerImpl server;
+ final ExchangeImpl t;
+ final ServerImpl server;
protected boolean closed = false;
protected boolean eof = false;
byte[] one = new byte [1];
@@ -109,6 +109,9 @@ abstract class LeftOverInputStream extends FilterInputStream {
int bufSize = 2048;
byte[] db = new byte [bufSize];
while (l > 0) {
+ if (server.isFinishing()) {
+ break;
+ }
long len = readImpl (db, 0, bufSize);
if (len == -1) {
eof = true;
diff --git a/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java b/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java
index a5adbf609..271a5bbc7 100644
--- a/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java
+++ b/jdk/src/share/classes/sun/net/httpserver/ServerImpl.java
@@ -219,6 +219,10 @@ class ServerImpl {
return httpsConfig;
}
+ public final boolean isFinishing() {
+ return finished;
+ }
+
public void stop (int delay) {
if (delay < 0) {
throw new IllegalArgumentException ("negative delay parameter");
--
2.19.1
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/lyn1001/openjdk-1.8.0.git
git@gitee.com:lyn1001/openjdk-1.8.0.git
lyn1001
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助