close inputFileStream 47/30847/1
authorSantosh Yadav <santosh.k.yadav@ril.com>
Thu, 8 Feb 2018 11:24:32 +0000 (16:54 +0530)
committerSantosh Yadav <santosh.k.yadav@ril.com>
Thu, 8 Feb 2018 11:24:32 +0000 (16:54 +0530)
used try catch resource
line no:367

Change-Id: I6c064ff34cba3a59a2924d25fa9ad58d97927a24
Issue-ID: VFC-698
Signed-off-by: Santosh Yadav <santosh.k.yadav@ril.com>
ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java

index 1b97a6e..b15c83d 100644 (file)
@@ -339,17 +339,12 @@ public class TaskThread implements Runnable {
 
        public boolean processPMCsv(File tempfile) {
 
-               FileInputStream brs = null;
-               InputStreamReader isr = null;
-               BufferedReader br = null;
-
                List<String> columnNames = new ArrayList<String>();
                List<String> commonValues = new ArrayList<String>();
-               try {
+               try (FileInputStream brs = new FileInputStream(tempfile);
+                               InputStreamReader isr = new InputStreamReader(brs, Constant.ENCODING_UTF8);
+                               BufferedReader br = new BufferedReader(isr)) {
 
-                       brs = new FileInputStream(tempfile);
-                       isr = new InputStreamReader(brs, Constant.ENCODING_UTF8);
-                       br = new BufferedReader(isr);
                        // common field
                        String commonField = br.readLine();
                        String[] fields = commonField.split("\\|", -1);
@@ -386,25 +381,12 @@ public class TaskThread implements Runnable {
                                        pmResultChannel.put(resultMap);
                                } catch (InterruptedException e) {
                                        log.error("collectResultChannel.put(resultMap) error ", e);
-                                       throw new RuntimeException(e);
                                }
                                valuelist.clear();
                        }
                } catch (IOException e) {
                        log.error("processPMCsv is fail ", e);
                        return false;
-               } finally {
-                       try {
-                               if (br != null)
-                                       br.close();
-                               if (isr != null)
-                                       isr.close();
-                               if (brs != null)
-                                       brs.close();
-
-                       } catch (Exception e) {
-                               log.error(e);
-                       }
                }
                return true;