Fix some small SONAR issues
Change-Id: I5accbeb3895e5a5e679146c9eb688232fbf0a6b6
diff --git a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingFloatingIpHandler.java b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingFloatingIpHandler.java
index 8a45968..b34ae9c 100644
--- a/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingFloatingIpHandler.java
+++ b/apps/openstacknetworking/src/main/java/org/onosproject/openstacknetworking/impl/OpenstackRoutingFloatingIpHandler.java
@@ -82,7 +82,7 @@
private final Logger log = LoggerFactory.getLogger(getClass());
private static final String ERR_FLOW = "Failed set flows for floating IP %s: ";
- private static final String ERR_UNSUPPORTED_NET_TYPE = "Unsupported network type";
+ private static final String ERR_UNSUPPORTED_NET_TYPE = "Unsupported network type %s";
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -180,7 +180,7 @@
break;
default:
final String error = String.format(
- ERR_UNSUPPORTED_NET_TYPE + "%s",
+ ERR_UNSUPPORTED_NET_TYPE,
osNet.getNetworkType().toString());
throw new IllegalStateException(error);
}
@@ -260,7 +260,7 @@
.setOutput(gNode.vlanPortNum());
break;
default:
- final String error = String.format(ERR_UNSUPPORTED_NET_TYPE + "%s",
+ final String error = String.format(ERR_UNSUPPORTED_NET_TYPE,
osNet.getNetworkType());
throw new IllegalStateException(error);
}
@@ -302,7 +302,7 @@
.setOutput(PortNumber.IN_PORT);
break;
default:
- final String error = String.format(ERR_UNSUPPORTED_NET_TYPE + "%s",
+ final String error = String.format(ERR_UNSUPPORTED_NET_TYPE,
osNet.getNetworkType());
throw new IllegalStateException(error);
}
@@ -333,7 +333,7 @@
sBuilder.matchVlanId(VlanId.vlanId(osNet.getProviderSegID()));
break;
default:
- final String error = String.format(ERR_UNSUPPORTED_NET_TYPE + "%s",
+ final String error = String.format(ERR_UNSUPPORTED_NET_TYPE,
osNet.getNetworkType());
throw new IllegalStateException(error);
}
diff --git a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java
index 5baa6a9..98d5d4a 100644
--- a/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java
+++ b/apps/segmentrouting/app/src/main/java/org/onosproject/segmentrouting/DefaultRoutingHandler.java
@@ -1596,7 +1596,7 @@
boolean sameResult = prevRun.equals(thisRun);
log.debug("dev:{} prevRun:{} thisRun:{} sameResult:{}", devId, prevRun,
thisRun, sameResult);
- if (thisRun == null || !sameResult || (sameResult && --constantAttempts > 0)) {
+ if (thisRun == null || !sameResult || (--constantAttempts > 0)) {
// exponentially increasing intervals for retries
executorService.schedule(this,
RETRY_INTERVAL_MS * (int) Math.pow(counter, RETRY_INTERVAL_SCALE),
diff --git a/drivers/server/src/main/java/org/onosproject/drivers/server/BasicServerDriver.java b/drivers/server/src/main/java/org/onosproject/drivers/server/BasicServerDriver.java
index e270b43..fa8ee63 100644
--- a/drivers/server/src/main/java/org/onosproject/drivers/server/BasicServerDriver.java
+++ b/drivers/server/src/main/java/org/onosproject/drivers/server/BasicServerDriver.java
@@ -66,6 +66,7 @@
*/
protected static RestSBController controller = null;
protected static DriverHandler handler = null;
+ private static final Object CONTROLLER_LOCK = new Object();
public BasicServerDriver() {};
@@ -78,18 +79,16 @@
* or the controller cannot be retrieved.
*/
private void init() {
- // Already done
- if ((handler != null) && (controller != null)) {
- return;
- }
+ synchronized (CONTROLLER_LOCK) {
+ // Already done
+ if ((handler != null) && (controller != null)) {
+ return;
+ }
- try {
handler = handler();
checkNotNull(handler, HANDLER_NULL);
controller = handler.get(RestSBController.class);
checkNotNull(controller, CONTROLLER_NULL);
- } catch (ServiceNotFoundException e) {
- throw e;
}
}
@@ -101,10 +100,11 @@
* @return RestSBController instance
*/
protected RestSBController getController() {
- if (controller == null) {
- init();
+ synchronized (CONTROLLER_LOCK) {
+ if (controller == null) {
+ init();
+ }
}
-
return controller;
}
@@ -116,8 +116,10 @@
* @return DriverHandler instance
*/
protected DriverHandler getHandler() {
- if (handler == null) {
- init();
+ synchronized (CONTROLLER_LOCK) {
+ if (handler == null) {
+ init();
+ }
}
return handler;
diff --git a/drivers/server/src/main/java/org/onosproject/drivers/server/ServerDevicesDiscovery.java b/drivers/server/src/main/java/org/onosproject/drivers/server/ServerDevicesDiscovery.java
index c5934f5..3adb0b4 100644
--- a/drivers/server/src/main/java/org/onosproject/drivers/server/ServerDevicesDiscovery.java
+++ b/drivers/server/src/main/java/org/onosproject/drivers/server/ServerDevicesDiscovery.java
@@ -415,7 +415,6 @@
Thread.sleep(1);
} catch (InterruptedException intEx) {
// Just retry
- } finally {
continue;
}
}