Skip to content

Commit

Permalink
Merge pull request #2058 from Dlalran/master
Browse files Browse the repository at this point in the history
[ISSUE #2056] Use try-with-resources to manage resources
close #2056
  • Loading branch information
xwm1992 authored Nov 2, 2022
2 parents 7d6b428 + 14e792a commit 6759c0a
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ public RejectClientByIpPortHandler(EventMeshTCPServer eventMeshTCPServer) {
@Override
public void handle(HttpExchange httpExchange) throws IOException {
String result = "";
OutputStream out = httpExchange.getResponseBody();
try {
try (OutputStream out = httpExchange.getResponseBody()) {
String queryString = httpExchange.getRequestURI().getQuery();
Map<String, String> queryStringInfo = NetUtils.formData2Dic(queryString);
String ip = queryStringInfo.get(EventMeshConstants.MANAGE_IP);
Expand Down Expand Up @@ -98,14 +97,6 @@ public void handle(HttpExchange httpExchange) throws IOException {
out.write(result.getBytes(Constants.DEFAULT_CHARSET));
} catch (Exception e) {
logger.error("rejectClientByIpPort fail...", e);
} finally {
if (out != null) {
try {
out.close();
} catch (IOException e) {
logger.warn("out close failed...", e);
}
}
}

}
Expand Down

0 comments on commit 6759c0a

Please sign in to comment.