Skip to content

Commit

Permalink
#436 Correct to close properly.
Browse files Browse the repository at this point in the history
fix #436
  • Loading branch information
SawamiWataru committed Jun 20, 2019
1 parent 024bbab commit a5fec17
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/java/io/personium/core/bar/BarFileInstaller.java
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ private File storeTemporaryBarFile(InputStream inStream) {
try {
sync(((FileOutputStream) outStream).getFD());
} catch (Exception e) {
IOUtils.closeQuietly(outStream);
throw PersoniumCoreException.Server.FILE_SYSTEM_ERROR.params(e.getMessage());
}
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/personium/core/rs/cell/LogResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ private Response getLog(final String logCollection, String logFileName) {
throw PersoniumCoreException.Dav.RESOURCE_NOT_FOUND.params(split[split.length - 1]);
} catch (IOException e) {
log.info("Failed to read archive entry : " + e.getMessage());
IOUtils.closeQuietly(bis);
throw PersoniumCoreException.Event.ARCHIVE_FILE_CANNOT_OPEN;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.HttpClientUtils;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
Expand Down Expand Up @@ -430,7 +430,6 @@ private List<OProperty<?>> requestHttpReceivedMessage(
String requestUrl = requestCellUrl + "__message/port";

//Acquire request header, add content below
HttpClient client = HttpClientFactory.create(HttpClientFactory.TYPE_INSECURE);
HttpPost req = new HttpPost(requestUrl);

//Request body
Expand All @@ -450,7 +449,7 @@ private List<OProperty<?>> requestHttpReceivedMessage(

//Throw a request
HttpResponse objResponse = null;
try {
try (CloseableHttpClient client = HttpClientFactory.create(HttpClientFactory.TYPE_INSECURE)) {
objResponse = client.execute(req);

//Create Request Result
Expand All @@ -469,7 +468,6 @@ private List<OProperty<?>> requestHttpReceivedMessage(
throw PersoniumCoreException.SentMessage.SM_CONNECTION_ERROR.reason(ioe);
} finally {
HttpClientUtils.closeQuietly(objResponse);
HttpClientUtils.closeQuietly(client);
}

}
Expand Down

0 comments on commit a5fec17

Please sign in to comment.