Fixed sonar critical issues fixes for Restconf Client.
Change-Id: If946c43ec98d31999da0829df41efb0a60ff5f7f
Issue-ID: CCSDK-325
Signed-off-by: Gaurav Agrawal <gaurav.agrawal@huawei.com>
     private static final Logger log = LoggerFactory.getLogger(
             RestconfApiCallNode.class);
 
-    /**
-     * Creates an instance of restconf api call node.
-     */
-    public RestconfApiCallNode() {
-    }
 
     /**
      * Sends the restconf request using the parameters map and the memory
 
         if (dir.exists()) {
             File[] files = dir.listFiles();
             if (files != null) {
-                for (File file : files) {
-                    if (file.isFile() && file.getName().endsWith(YANG)) {
-                        yangFiles.add(file);
-                    } else if (file.isDirectory()) {
-                        getYangFiles(file, yangFiles);
-                    }
-                }
+                processFiles(files, yangFiles);
+            }
+        }
+    }
+
+    private static void processFiles(File[] files, List<File> yangFiles) {
+        for (File file : files) {
+            if (file.isFile() && file.getName().endsWith(YANG)) {
+                yangFiles.add(file);
+            } else if (file.isDirectory()) {
+                getYangFiles(file, yangFiles);
             }
         }
     }
 
     public void onEvent(InboundEvent event) {
         String payload = event.readData();
         if (!node.eventQueue().offer(payload)) {
-            log.error("Unable to process event "
-                              + payload + "as processing queue is full");
-            throw new RuntimeException("Unable to process event "
-                                               + payload
-                                               + "as processing queue is full");
+            log.error("Unable to process event {} as processing queue is full", payload);
         }
     }
 }
 
                 String id = param.get(EVENT_SUBSCRIPTION_ID);
                 SubscriptionInfo info = node.subscriptionInfoMap().get(id);
                 if (info != null) {
-                    SvcLogicContext ctx = new SvcLogicContext();
-                    for (Map.Entry<String, String> entry : param.entrySet()) {
-                        ctx.setAttribute(entry.getKey(), entry.getValue());
-                    }
+                    SvcLogicContext ctx = setContext(param);
                     SvcLogicGraphInfo callbackDG = info.callBackDG();
                     callbackDG.executeGraph(ctx);
                 }
             } catch (InterruptedException | SvcLogicException e) {
-                log.error(e.getMessage());
-                throw new RuntimeException(e.getMessage());
+                log.error("Interrupted!", e);
+                Thread.currentThread().interrupt();
             }
         }
     }
+
+    private SvcLogicContext setContext(Map<String, String> param) {
+        SvcLogicContext ctx = new SvcLogicContext();
+        for (Map.Entry<String, String> entry : param.entrySet()) {
+            ctx.setAttribute(entry.getKey(), entry.getValue());
+        }
+        return ctx;
+    }
 }
 
 
             establishPersistentConnection(paramMap, ctx, subscriberId);
         } else {
-            log.info("Failed to subscribe " + subscriberId);
+            log.info("Failed to subscribe {}", subscriberId);
             throw new SvcLogicException(ctx.getAttribute(RESPONSE_CODE));
         }
     }
                 try {
                     Thread.sleep(5000);
                 } catch (InterruptedException e) {
-                    log.error("Exception: " + e.getMessage());
+                    log.error("Interrupted!", e);
+                    Thread.currentThread().interrupt();
                 }
             }
             eventSource.close();