diff --git a/src/main/java/io/personium/core/bar/BarFileInstaller.java b/src/main/java/io/personium/core/bar/BarFileInstaller.java index a1ae8d1a0..3dc413629 100644 --- a/src/main/java/io/personium/core/bar/BarFileInstaller.java +++ b/src/main/java/io/personium/core/bar/BarFileInstaller.java @@ -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()); } } diff --git a/src/main/java/io/personium/core/rs/cell/LogResource.java b/src/main/java/io/personium/core/rs/cell/LogResource.java index 1f76971d5..946be474d 100644 --- a/src/main/java/io/personium/core/rs/cell/LogResource.java +++ b/src/main/java/io/personium/core/rs/cell/LogResource.java @@ -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; } } diff --git a/src/main/java/io/personium/core/rs/odata/ODataSentMessageResource.java b/src/main/java/io/personium/core/rs/odata/ODataSentMessageResource.java index 6d05f332b..8aa280254 100644 --- a/src/main/java/io/personium/core/rs/odata/ODataSentMessageResource.java +++ b/src/main/java/io/personium/core/rs/odata/ODataSentMessageResource.java @@ -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; @@ -430,7 +430,6 @@ private List> 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 @@ -450,7 +449,7 @@ private List> requestHttpReceivedMessage( //Throw a request HttpResponse objResponse = null; - try { + try (CloseableHttpClient client = HttpClientFactory.create(HttpClientFactory.TYPE_INSECURE)) { objResponse = client.execute(req); //Create Request Result @@ -469,7 +468,6 @@ private List> requestHttpReceivedMessage( throw PersoniumCoreException.SentMessage.SM_CONNECTION_ERROR.reason(ioe); } finally { HttpClientUtils.closeQuietly(objResponse); - HttpClientUtils.closeQuietly(client); } }