Fix few Blocker/Critical sonar issues 55/11055/2
authorramu.n <ramu.n@huawei.com>
Fri, 8 Sep 2017 09:15:31 +0000 (14:45 +0530)
committerramu.n <ramu.n@huawei.com>
Fri, 8 Sep 2017 12:54:03 +0000 (18:24 +0530)
Fix few Blocker/Critical sonar issues in sdnc northbound modules
https://sonar.onap.org/component_issues?id=org.openecomp.sdnc.northbound%3Asdnc-northbound#resolved=false|severities=BLOCKER%2CCRITICAL

Change-Id: I277dd72784a2186acffdd2a7045fecbef528f56b
Issue-Id: SDNC-65
Signed-off-by: Ramu N <ramu.n@huawei.com>
vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java
vnftools/provider/src/main/java/org/onap/sdnc/vnftools/VnfTools.java

index 83fb260..9893235 100644 (file)
@@ -486,7 +486,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
             default:
                 log.error("Unknown RequestAction: " + requestInformation.getRequestAction() );
                 break;
-            };
+            }
         }
         if (requestInformation != null && requestInformation.getRequestSubAction() != null) {
             switch (requestInformation.getRequestSubAction())
@@ -500,7 +500,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
             default:
                 log.error("Unknown RequestSubAction: " + requestInformation.getRequestSubAction() );
                 break;
-            };
+            }
         }
     }
 
@@ -533,7 +533,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
             default:
                 log.error("Unknown SvcAction: " + requestHeader.getSvcAction() );
                 break;
-            };
+            }
         }
     }
 
@@ -1744,7 +1744,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
 
         // Grab the service instance ID from the input buffer
         String siid = null;
-        if (input.getSdncRequestHeader().getSvcAction().equals("assign")) {
+        if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Assign)) {
             siid = input.getNetworkRequestInformation().getNetworkName();
         }
         else {
index b3497bd..fb95a41 100644 (file)
@@ -8,9 +8,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -23,6 +23,7 @@ package org.onap.sdnc.vnftools;
 
 import java.io.File;
 import java.io.FileOutputStream;
+import java.io.IOException;
 import java.io.PrintStream;
 import java.util.ArrayList;
 import java.util.List;
@@ -161,16 +162,26 @@ public class VnfTools implements SvcLogicJavaPlugin {
                }
 
                PrintStream pstr = null;
+               FileOutputStream fileStream = null;
 
                try {
-                       pstr = new PrintStream(new FileOutputStream(new File(fileName), true));
+                       pstr = new PrintStream(fileStream = new FileOutputStream(new File(fileName), true));
                } catch (Exception e) {
+                       if (fileStream != null) {
+                               try {
+                                       fileStream.close();
+                               } catch (IOException e1) {
+                                       LOG.error("FileOutputStream close exception: ", e1);
+                               }
+                       }
                        throw new SvcLogicException("Cannot open file " + fileName, e);
                }
-               pstr.println("#######################################");
+
+               pstr.println("#######################################");
                for (String attr : ctx.getAttributeKeySet()) {
                        pstr.println(attr + " = " + ctx.getAttribute(attr));
                }
+
                pstr.flush();
                pstr.close();
        }