Fix some small SONAR issues

Change-Id: I5accbeb3895e5a5e679146c9eb688232fbf0a6b6
This commit is contained in:
Ray Milkey 2018-02-26 09:36:31 -08:00
parent 6be5c870c2
commit c6c9b17b7b
4 changed files with 20 additions and 19 deletions

View File

@ -82,7 +82,7 @@ public class OpenstackRoutingFloatingIpHandler {
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 @@ public class OpenstackRoutingFloatingIpHandler {
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 @@ public class OpenstackRoutingFloatingIpHandler {
.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 @@ public class OpenstackRoutingFloatingIpHandler {
.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 @@ public class OpenstackRoutingFloatingIpHandler {
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);
}

View File

@ -1596,7 +1596,7 @@ public class DefaultRoutingHandler {
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),

View File

@ -66,6 +66,7 @@ public class BasicServerDriver extends AbstractHandlerBehaviour {
*/
protected static RestSBController controller = null;
protected static DriverHandler handler = null;
private static final Object CONTROLLER_LOCK = new Object();
public BasicServerDriver() {};
@ -78,18 +79,16 @@ public class BasicServerDriver extends AbstractHandlerBehaviour {
* 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 @@ public class BasicServerDriver extends AbstractHandlerBehaviour {
* @return RestSBController instance
*/
protected RestSBController getController() {
if (controller == null) {
init();
synchronized (CONTROLLER_LOCK) {
if (controller == null) {
init();
}
}
return controller;
}
@ -116,8 +116,10 @@ public class BasicServerDriver extends AbstractHandlerBehaviour {
* @return DriverHandler instance
*/
protected DriverHandler getHandler() {
if (handler == null) {
init();
synchronized (CONTROLLER_LOCK) {
if (handler == null) {
init();
}
}
return handler;

View File

@ -415,7 +415,6 @@ public class ServerDevicesDiscovery extends BasicServerDriver
Thread.sleep(1);
} catch (InterruptedException intEx) {
// Just retry
} finally {
continue;
}
}