diff options
Diffstat (limited to 'rulemgt/src/main')
-rw-r--r-- | rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/SwaggerResource.java | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/SwaggerResource.java b/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/SwaggerResource.java index df5a8f1..8376daf 100644 --- a/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/SwaggerResource.java +++ b/rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/SwaggerResource.java @@ -43,11 +43,13 @@ public class SwaggerResource { public String getSwaggerJson() { URL url = SwaggerResource.class.getResource("/swagger.json"); String ret = "{}"; + + BufferedReader br = null; try { System.out.println(URLDecoder.decode(url.getPath(), "UTF-8")); File file = new File(URLDecoder.decode(url.getPath(), "UTF-8")); - BufferedReader br = new BufferedReader(new FileReader(file)); + br = new BufferedReader(new FileReader(file)); StringBuffer buffer = new StringBuffer(); String line = " "; while ((line = br.readLine()) != null) { @@ -55,10 +57,19 @@ public class SwaggerResource { } ret = buffer.toString(); } catch (FileNotFoundException e) { - log.warn("Failed to read the API description file."); + log.warn("Failed to read the API description file.", e); } catch (IOException e) { - log.warn("An error occurred while reading swagger.json."); + log.warn("An error occurred while reading swagger.json.", e); + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException e) { + log.warn("Failed to close the file reader. This may cause memory leak."); + } + } } + return ret; } } |