Fix file stream closing
[aai/data-router.git] / src / main / java / org / onap / aai / datarouter / util / SearchServiceAgent.java
index 42861b4..bbdb4c8 100644 (file)
@@ -320,8 +320,7 @@ public class SearchServiceAgent {
    * Removes a document from the Search Service.\r
    * \r
    * @param index   - The index to create the document in.\r
-   * @param id      - The identifier for the document.\r
-   * @param payload - The document contents.\r
+   * @param documentId      - The identifier for the document.\r
    * @param headers - HTTP headers.\r
    */\r
   public void deleteDocument(String index, String documentId, Map<String, List<String>> headers) {\r
@@ -340,12 +339,13 @@ public class SearchServiceAgent {
    */\r
   protected String loadFileData(String filename) throws Exception {\r
     StringBuilder data = new StringBuilder();\r
-    try {\r
-      BufferedReader in = new BufferedReader(new InputStreamReader(\r
-          EntityEventPolicy.class.getClassLoader().getResourceAsStream("/" + filename),\r
-          StandardCharsets.UTF_8));\r
-      String line;\r
 \r
+    try (InputStreamReader inputStreamReader = new InputStreamReader(EntityEventPolicy.class.getClassLoader()\r
+        .getResourceAsStream("/" + filename), StandardCharsets.UTF_8); BufferedReader in = new BufferedReader(\r
+        inputStreamReader)\r
+    ) {\r
+\r
+      String line;\r
       while ((line = in.readLine()) != null) {\r
         data.append(line);\r
       }\r