summaryrefslogtreecommitdiffstats
path: root/rulemgt/src/main/java/org/onap
diff options
context:
space:
mode:
authorGuangrong Fu <fu.guangrong@zte.com.cn>2018-01-26 16:46:12 +0800
committerGuangrong Fu <fu.guangrong@zte.com.cn>2018-01-26 16:46:12 +0800
commit4be2442687589c409a469188696d7605979881ee (patch)
tree68fd90e3faa518525385b23c971d845160b14244 /rulemgt/src/main/java/org/onap
parentd2491cd6801ecd030c904d2a404df65de9024126 (diff)
Fix Sonar Issues
Change-Id: I10514d76c86fbe8d1860bfb09be4cf2f5f6ffdbb Issue-ID: HOLMES-116 Signed-off-by: Guangrong Fu <fu.guangrong@zte.com.cn>
Diffstat (limited to 'rulemgt/src/main/java/org/onap')
-rw-r--r--rulemgt/src/main/java/org/onap/holmes/rulemgt/resources/SwaggerResource.java17
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;
}
}