diff options
author | s00370346 <swarup.nayak1@huawei.com> | 2019-07-12 11:35:54 +0530 |
---|---|---|
committer | s00370346 <swarup.nayak1@huawei.com> | 2019-07-12 14:50:21 +0530 |
commit | c818065d90aad39e61992ee44fa13568b80ee7b3 (patch) | |
tree | 02126cd73fbdd7c825b7a120a54699fb340ba3ac /src/main/java/org | |
parent | 20d8093fd688f0385b7bb9b8e4b09ff60ef23f26 (diff) |
Issue-ID: DCAEGEN2-1661 Fix Some Compilation warnings, sonar issue
Signed-off-by: s00370346 <swarup.nayak1@huawei.com>
Change-Id: Id01028b87c101ff2544d93c68a59f9cc46020d8d
Diffstat (limited to 'src/main/java/org')
5 files changed, 20 insertions, 16 deletions
diff --git a/src/main/java/org/onap/dcae/common/DataChangeEventListener.java b/src/main/java/org/onap/dcae/common/DataChangeEventListener.java index 6cf2291..b37730e 100755 --- a/src/main/java/org/onap/dcae/common/DataChangeEventListener.java +++ b/src/main/java/org/onap/dcae/common/DataChangeEventListener.java @@ -60,7 +60,7 @@ public class DataChangeEventListener implements EventListener { log.info("Received heart beat "); } } catch (Exception e) { - log.info("InboundEvent event is malformed"); + log.info("InboundEvent event is malformed " + e); } } @@ -75,6 +75,7 @@ public class DataChangeEventListener implements EventListener { } catch (JSONException ex) { try { new JSONArray(test); + return jsonType.ARRAY; } catch (JSONException ex1) { return jsonType.NONE; diff --git a/src/main/java/org/onap/dcae/common/EventConnectionState.java b/src/main/java/org/onap/dcae/common/EventConnectionState.java index 3e53247..83d3c85 100644 --- a/src/main/java/org/onap/dcae/common/EventConnectionState.java +++ b/src/main/java/org/onap/dcae/common/EventConnectionState.java @@ -22,7 +22,7 @@ package org.onap.dcae.common; public enum EventConnectionState { - INIT, SUBSCRIBED, UNSUBSCRIBED, Unspecified; + INIT, SUBSCRIBED, UNSUBSCRIBED, UNSPECIFIED; public static EventConnectionState fromString(String s) { if ("init".equalsIgnoreCase(s)) { @@ -35,7 +35,7 @@ public enum EventConnectionState { return UNSUBSCRIBED; } if ("unspecified".equalsIgnoreCase(s)) { - return Unspecified; + return UNSPECIFIED; } throw new IllegalArgumentException("Invalid value for format: " + s); } diff --git a/src/main/java/org/onap/dcae/common/EventProcessor.java b/src/main/java/org/onap/dcae/common/EventProcessor.java index 1879700..f870d3f 100644 --- a/src/main/java/org/onap/dcae/common/EventProcessor.java +++ b/src/main/java/org/onap/dcae/common/EventProcessor.java @@ -56,8 +56,8 @@ public class EventProcessor implements Runnable { while (true) {
ev = RestConfCollector.fProcessingInputQueue.take();
- // As long as the producer is running we remove elements from
- // the queue.
+ /* As long as the producer is running we remove elements from
+ * the queue */
log.info("QueueSize:" + RestConfCollector.fProcessingInputQueue.size() + "\tEventProcessor\tRemoving element: " +
ev.getEventObj());
/*@TODO: Right now all event publish to single domain and consume by VES collector. Later maybe send to specific domain */
@@ -72,7 +72,7 @@ public class EventProcessor implements Runnable { }
} catch (Exception e) {
- log.error("EventProcessor InterruptedException" + e.getMessage());
+ log.error("EventProcessor InterruptedException " + e);
Thread.currentThread().interrupt();
}
}
@@ -87,7 +87,7 @@ public class EventProcessor implements Runnable { log.info("Invoking method " + ev.getConn().getModifyMethod() + " isModify " + ev.getConn().isModifyEvent());
modifiedObj = (JSONObject)(this.getClass().getMethod(ev.getConn().getModifyMethod(),
EventData.class, String.class).invoke(this, ev, ev.getConn().getUserData()));
- }catch (Exception e) {
+ } catch (Exception e) {
log.warn("No such method exist" + e);
}
}
@@ -127,9 +127,7 @@ public class EventProcessor implements Runnable { JSONObject finalObj = new JSONObject();
Path configFile = Paths.get(conn.getParentCtrllr().getProperties().controllerConfigFileLocation());
try {
- //log.info("Paths " + configFile.toString());
String bytes = new String(Files.readAllBytes(configFile));
- //log.info("Bytes " + bytes);
newJSON = new JSONObject(bytes);
newJSON.put("serialNumber", json1.getJSONObject("notification").getJSONObject("message").getJSONObject("content").getJSONObject("onu").get("sn"));
newJSON.put("softwareVersion", json1.getJSONObject("notification").getJSONObject("message").get("version"));
@@ -181,11 +179,9 @@ public class EventProcessor implements Runnable { newJSON.put("vendorName", usrDataMap.get("vendorName"));
}
}
- //additionalfields.put("remote-id", attachment-point);
} catch (Exception e) {
log.info("File reading error " + e);
}
- //log.info("Modified json " + newJSON);
finalObj.put("pnfRegistration", newJSON);
log.info("final obj"+ finalObj.toString());
return finalObj;
diff --git a/src/main/java/org/onap/dcae/common/publishing/VavrUtils.java b/src/main/java/org/onap/dcae/common/publishing/VavrUtils.java index 1db4e18..209aa82 100644 --- a/src/main/java/org/onap/dcae/common/publishing/VavrUtils.java +++ b/src/main/java/org/onap/dcae/common/publishing/VavrUtils.java @@ -32,11 +32,14 @@ import static io.vavr.API.$; public final class VavrUtils { private VavrUtils() { - // utils aggregator + /* utils aggregator */ } /** * Shortcut for 'string interpolation' + * @param msg String message + * @param args var args + * @return String */ public static String f(String msg, Object... args) { return String.format(msg, args); @@ -45,6 +48,8 @@ public final class VavrUtils { /** * Wrap failure with a more descriptive message of what has failed and chain original cause. Used to provide a * context for errors instead of raw exception. + * @param msg String message + * @return Case */ public static Case<Throwable, Throwable> enhanceError(String msg) { return API.Case($(), e -> new RuntimeException(msg, e)); diff --git a/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java b/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java index ecbec31..7434fc2 100644 --- a/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java +++ b/src/main/java/org/onap/dcae/controller/PersistentEventConnection.java @@ -180,7 +180,7 @@ public class PersistentEventConnection implements Runnable { @Override public void run() { - int sleep_time = 5000; + long sleep_time = 5000; boolean openState = false; EventSource eventSrc = null; while (running) { @@ -203,7 +203,9 @@ public class PersistentEventConnection implements Runnable { } catch (InterruptedException ie) { log.info("Exception: " + ie.getMessage()); running = false; - eventSrc.close(); + if (eventSrc != null) { + eventSrc.close(); + } Thread.currentThread().interrupt(); return; } catch (Exception e){ @@ -217,7 +219,7 @@ public class PersistentEventConnection implements Runnable { } } try { - if (eventSrc.isOpen()) { + if ((eventSrc != null) && (eventSrc.isOpen())) { eventSrc.close(); } }catch (Exception e) { @@ -243,7 +245,7 @@ public class PersistentEventConnection implements Runnable { log.error("Failed to receive sbscription notiication, trying again", e); try { parentCtrllr.getRestApiCallNode().sendRequest(eventParaMap, ctx, null); - }catch (Exception ex){ + } catch (Exception ex){ log.error("Exception occured again! Trying again", e); Thread.currentThread().interrupt(); } |