Fix for Sonar Blocker issues 61/13461/4
authorrama-huawei <rama.subba.reddy.s@huawei.com>
Tue, 19 Sep 2017 12:39:33 +0000 (18:09 +0530)
committerRama SubbaReddy <rama.subba.reddy.s@huawei.com>
Tue, 19 Sep 2017 14:57:52 +0000 (14:57 +0000)
NullPointerException might be thrown

DCAEGEN2-114

Change-Id: I79d82683e71a913d4446f07fe41af2be7174e92b
Signed-off-by: rama-huawei <rama.subba.reddy.s@huawei.com>
src/main/java/com/att/nsa/dmaap/filemonitor/ServicePropertyService.java

index e4f4e03..9f9c862 100644 (file)
@@ -90,7 +90,7 @@ public class ServicePropertyService {
                FileInputStream fis = null;
 
                if (fileList == null)
-                       fileList = new ArrayList<File>();
+                       fileList = new ArrayList<>();
 
                // get all the files that are ".json" or ".properties", from a directory
                // & it's sub-directories
@@ -110,7 +110,9 @@ public class ServicePropertyService {
                                } catch (Exception ioe) {
                                        logger.error("Error reading the file stream ", ioe);
                                } finally {
-                                       fis.close();
+                                       if (fis != null) {
+                                               fis.close();
+                                       }
                                }
                        } else if (file.isDirectory()) {
                                getFileList(file.getPath());