mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix code
This commit is contained in:
@@ -50,7 +50,7 @@ public interface HttpBody {
|
||||
try {
|
||||
write(out);
|
||||
} finally {
|
||||
IoUtil.close(out);
|
||||
IoUtil.closeQuietly(out);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -127,7 +127,7 @@ public class MultipartOutputStream extends OutputStream {
|
||||
@Override
|
||||
public void close() {
|
||||
finish();
|
||||
IoUtil.close(this.out);
|
||||
IoUtil.closeQuietly(this.out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -106,7 +106,7 @@ public class ResponseBody implements HttpBody, Closeable {
|
||||
return this.bodyStream.copyTo(out, streamProgress);
|
||||
} finally {
|
||||
if (isCloseOut) {
|
||||
IoUtil.close(out);
|
||||
IoUtil.closeQuietly(out);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public class HttpClient4Engine implements ClientEngine {
|
||||
public HttpClient4Engine setConfig(final ClientConfig config) {
|
||||
this.config = config;
|
||||
// 重置客户端
|
||||
IoUtil.close(this.engine);
|
||||
IoUtil.closeQuietly(this.engine);
|
||||
this.engine = null;
|
||||
return this;
|
||||
}
|
||||
|
@@ -53,7 +53,7 @@ public class HttpClient5Engine implements ClientEngine {
|
||||
public HttpClient5Engine setConfig(final ClientConfig config) {
|
||||
this.config = config;
|
||||
// 重置客户端
|
||||
IoUtil.close(this.engine);
|
||||
IoUtil.closeQuietly(this.engine);
|
||||
this.engine = null;
|
||||
return this;
|
||||
}
|
||||
|
@@ -66,7 +66,7 @@ public class JdkClientEngine implements ClientEngine {
|
||||
doSend(message);
|
||||
} catch (final IOException e) {
|
||||
// 出错后关闭连接
|
||||
IoUtil.close(this);
|
||||
IoUtil.closeQuietly(this);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class JdkClientEngine implements ClientEngine {
|
||||
*/
|
||||
private void initConn(final Request message) {
|
||||
// 执行下次请求时自动关闭上次请求(常用于转发)
|
||||
IoUtil.close(this);
|
||||
IoUtil.closeQuietly(this);
|
||||
|
||||
this.conn = buildConn(message);
|
||||
}
|
||||
|
@@ -202,7 +202,7 @@ public class JdkHttpResponse implements Response, Closeable {
|
||||
@Override
|
||||
public void close() {
|
||||
// 关闭流
|
||||
IoUtil.close(this.body);
|
||||
IoUtil.closeQuietly(this.body);
|
||||
// 关闭连接
|
||||
this.httpConnection.disconnectQuietly();
|
||||
}
|
||||
|
@@ -351,8 +351,8 @@ public class HttpServerResponse extends HttpServerBase {
|
||||
out = this.httpExchange.getResponseBody();
|
||||
IoUtil.copy(in, out);
|
||||
} finally {
|
||||
IoUtil.close(out);
|
||||
IoUtil.close(in);
|
||||
IoUtil.closeQuietly(out);
|
||||
IoUtil.closeQuietly(in);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
@@ -391,7 +391,7 @@ public class HttpServerResponse extends HttpServerBase {
|
||||
in = FileUtil.getInputStream(file);
|
||||
write(in, (int)fileSize, contentType, fileName);
|
||||
} finally {
|
||||
IoUtil.close(in);
|
||||
IoUtil.closeQuietly(in);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@@ -540,7 +540,7 @@ public class SoapClient implements HeaderOperation<SoapClient> {
|
||||
} catch (final IOException | SOAPException e) {
|
||||
throw new SoapRuntimeException(e);
|
||||
} finally {
|
||||
IoUtil.close(res);
|
||||
IoUtil.closeQuietly(res);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -25,6 +25,6 @@ public class Issue2901Test {
|
||||
.send();
|
||||
|
||||
Console.log(res.bodyStr());
|
||||
IoUtil.close(res);
|
||||
IoUtil.closeQuietly(res);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user