SONAR suggestion - generic exceptions
Replace uses of generic RuntimeException
with more appropriate unchecked exceptions
Change-Id: If283743c2cf7252b8d280bdb788708ebbe57da9d
diff --git a/core/api/src/main/java/org/onosproject/net/pi/model/DefaultPiPipeconf.java b/core/api/src/main/java/org/onosproject/net/pi/model/DefaultPiPipeconf.java
index b6cea63..7d9dd28 100644
--- a/core/api/src/main/java/org/onosproject/net/pi/model/DefaultPiPipeconf.java
+++ b/core/api/src/main/java/org/onosproject/net/pi/model/DefaultPiPipeconf.java
@@ -80,7 +80,7 @@
try {
return Optional.of(extensions.get(type).openStream());
} catch (IOException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
} else {
return Optional.empty();
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/AbstractCriterionTranslator.java b/core/net/src/main/java/org/onosproject/net/pi/impl/AbstractCriterionTranslator.java
index 4bbb123..36e9068 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/AbstractCriterionTranslator.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/AbstractCriterionTranslator.java
@@ -112,7 +112,7 @@
}
break;
default:
- throw new RuntimeException("Unrecognized init type " + initType.name());
+ throw new IllegalArgumentException("Unrecognized init type " + initType.name());
}
return value;
}
@@ -129,7 +129,7 @@
mask = getMaskFromPrefixLength(prefixLength, value.size());
break;
default:
- throw new RuntimeException("Unrecognized init type " + initType.name());
+ throw new IllegalArgumentException("Unrecognized init type " + initType.name());
}
return Pair.of(value, mask);
@@ -150,7 +150,7 @@
case LPM:
break;
default:
- throw new RuntimeException("Unrecognized init type " + initType.name());
+ throw new IllegalArgumentException("Unrecognized init type " + initType.name());
}
return Pair.of(value, prefixLength);
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslatorImpl.java b/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslatorImpl.java
index 430e5e1..3230f41 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslatorImpl.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/PiFlowRuleTranslatorImpl.java
@@ -428,7 +428,7 @@
return fieldMatch;
default:
// Should never be here.
- throw new RuntimeException(
+ throw new IllegalArgumentException(
"Unrecognized match type " + fieldModel.matchType().name());
}
} catch (ByteSequenceTrimException e) {
diff --git a/core/net/src/main/java/org/onosproject/net/pi/impl/PiUtils.java b/core/net/src/main/java/org/onosproject/net/pi/impl/PiUtils.java
index 78bca5f..6f8d33a 100644
--- a/core/net/src/main/java/org/onosproject/net/pi/impl/PiUtils.java
+++ b/core/net/src/main/java/org/onosproject/net/pi/impl/PiUtils.java
@@ -54,7 +54,8 @@
.orElse(null)
.newInstance();
} catch (InstantiationException | IllegalAccessException e) {
- throw new RuntimeException(format("Unable to instantiate interpreter of pipeconf %s", pipeconf.id()));
+ throw new IllegalArgumentException(format("Unable to instantiate interpreter of pipeconf %s",
+ pipeconf.id()));
}
}
}
diff --git a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
index a5c5f3b..d7e478b 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManager.java
@@ -158,7 +158,7 @@
protected ClusterMetadataService clusterMetadataService;
@Activate
- public void activate() throws Exception {
+ public void activate() throws InterruptedException {
ControllerNode localNode = clusterMetadataService.getLocalNode();
getTlsParameters();
@@ -179,7 +179,7 @@
}
@Deactivate
- public void deactivate() throws Exception {
+ public void deactivate() {
if (started.get()) {
serverGroup.shutdownGracefully();
clientGroup.shutdownGracefully();