SONAR suggestion - generic exceptions
Replace uses of generic RuntimeException
with more appropriate unchecked exceptions
Change-Id: If283743c2cf7252b8d280bdb788708ebbe57da9d
diff --git a/apps/artemis/src/main/java/org/onosproject/artemis/impl/moas/MoasClientController.java b/apps/artemis/src/main/java/org/onosproject/artemis/impl/moas/MoasClientController.java
index fccda3e..7c1e01f 100644
--- a/apps/artemis/src/main/java/org/onosproject/artemis/impl/moas/MoasClientController.java
+++ b/apps/artemis/src/main/java/org/onosproject/artemis/impl/moas/MoasClientController.java
@@ -82,18 +82,13 @@
* Bootstrap netty socket.
*
* @return bootstrap
- * @throws Exception exception
*/
- private Bootstrap createBootstrap() throws Exception {
- try {
- workerGroup = new NioEventLoopGroup();
- return new Bootstrap()
- .group(workerGroup)
- .channel(NioSocketChannel.class)
- .option(ChannelOption.SO_KEEPALIVE, true);
- } catch (Exception e) {
- throw new Exception(e);
- }
+ private Bootstrap createBootstrap() {
+ workerGroup = new NioEventLoopGroup();
+ return new Bootstrap()
+ .group(workerGroup)
+ .channel(NioSocketChannel.class)
+ .option(ChannelOption.SO_KEEPALIVE, true);
}
/**
diff --git a/apps/artemis/src/main/java/org/onosproject/artemis/impl/moas/MoasServerController.java b/apps/artemis/src/main/java/org/onosproject/artemis/impl/moas/MoasServerController.java
index c27a134..33e30d0 100644
--- a/apps/artemis/src/main/java/org/onosproject/artemis/impl/moas/MoasServerController.java
+++ b/apps/artemis/src/main/java/org/onosproject/artemis/impl/moas/MoasServerController.java
@@ -77,22 +77,17 @@
* Create netty server bootstrap.
*
* @return bootstrap
- * @throws Exception exception
*/
- private ServerBootstrap createServerBootStrap() throws Exception {
- try {
- bossGroup = new NioEventLoopGroup();
- workerGroup = new NioEventLoopGroup();
+ private ServerBootstrap createServerBootStrap() {
+ bossGroup = new NioEventLoopGroup();
+ workerGroup = new NioEventLoopGroup();
- return new ServerBootstrap()
- .group(bossGroup, workerGroup)
- .channel(NioServerSocketChannel.class)
- .option(ChannelOption.SO_REUSEADDR, true)
- .childOption(ChannelOption.SO_KEEPALIVE, true)
- .childOption(ChannelOption.TCP_NODELAY, true);
- } catch (Exception e) {
- throw new Exception(e);
- }
+ return new ServerBootstrap()
+ .group(bossGroup, workerGroup)
+ .channel(NioServerSocketChannel.class)
+ .option(ChannelOption.SO_REUSEADDR, true)
+ .childOption(ChannelOption.SO_KEEPALIVE, true)
+ .childOption(ChannelOption.TCP_NODELAY, true);
}
/**
diff --git a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMessageMetricMapper.java b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMessageMetricMapper.java
index bd541b4..92126bf 100644
--- a/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMessageMetricMapper.java
+++ b/apps/cpman/app/src/main/java/org/onosproject/cpman/impl/ControlMessageMetricMapper.java
@@ -58,7 +58,7 @@
*/
private static <I, O> O lookup(BiMap<I, O> map, I input, Class<O> cls) {
if (!map.containsKey(input)) {
- throw new RuntimeException(
+ throw new IllegalArgumentException(
String.format("No mapping found for %s when converting to %s",
input, cls.getName()));
}
diff --git a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnManager.java b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnManager.java
index 0cb86ab..45e9f9b 100644
--- a/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnManager.java
+++ b/apps/l3vpn/src/main/java/org/onosproject/l3vpn/netl3vpn/impl/NetL3VpnManager.java
@@ -240,7 +240,7 @@
value = l3VpnIdGen.getNewId();
}
if (value > ID_LIMIT) {
- throw new RuntimeException(ID_LIMIT_EXCEEDED);
+ throw new IllegalStateException(ID_LIMIT_EXCEEDED);
}
return CONS_HUNDRED + String.valueOf(value);
}
diff --git a/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfActiveComponent.java b/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfActiveComponent.java
index 2c35f26..92043d5 100644
--- a/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfActiveComponent.java
+++ b/apps/netconf/client/src/main/java/org/onosproject/netconf/client/impl/NetconfActiveComponent.java
@@ -212,7 +212,7 @@
if (node.type() == DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE) {
temp = ((LeafNode) node).asString().split("\\:");
if (temp.length != 3) {
- throw new RuntimeException(new NetconfException("Invalid device id form, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id form, cannot apply"));
}
ip = temp[1];
port = temp[2];
@@ -220,12 +220,12 @@
ListKey key = (ListKey) node.key();
temp = key.keyLeafs().get(0).leafValAsString().split("\\:");
if (temp.length != 3) {
- throw new RuntimeException(new NetconfException("Invalid device id form, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id form, cannot apply"));
}
ip = temp[1];
port = temp[2];
} else {
- throw new RuntimeException(new NetconfException("Invalid device id type, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id type, cannot apply"));
}
try {
return DeviceId.deviceId(new URI("netconf", ip + ":" + port, (String) null));
@@ -246,7 +246,7 @@
this.controller.connectDevice(deviceId);
//}
} catch (Exception ex) {
- throw new RuntimeException(new NetconfException("Unable to connect to NETCONF device on " +
+ throw new IllegalStateException(new NetconfException("Unable to connect to NETCONF device on " +
deviceId, ex));
}
}
@@ -263,21 +263,21 @@
String resId = ResourceIdParser.parseResId(path);
String[] el = resId.split(ResourceIdParser.EL_CHK);
if (el.length < 3) {
- throw new RuntimeException(new NetconfException("Invalid resource id, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid resource id, cannot apply"));
}
if (!el[2].contains((ResourceIdParser.KEY_SEP))) {
- throw new RuntimeException(new NetconfException("Invalid device id key, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id key, cannot apply"));
}
String[] keys = el[2].split(ResourceIdParser.KEY_CHK);
if (keys.length < 2) {
- throw new RuntimeException(new NetconfException("Invalid device id key, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id key, cannot apply"));
}
String[] parts = keys[1].split(ResourceIdParser.NM_CHK);
if (parts.length < 3) {
- throw new RuntimeException(new NetconfException("Invalid device id key, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id key, cannot apply"));
}
if (parts[2].split("\\:").length != 3) {
- throw new RuntimeException(new NetconfException("Invalid device id form, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id form, cannot apply"));
}
return (new ResourceId.Builder()
.addBranchPointSchema(el[1].split(ResourceIdParser.NM_CHK)[0],
@@ -299,23 +299,23 @@
String resId = ResourceIdParser.parseResId(path);
String[] el = resId.split(ResourceIdParser.EL_CHK);
if (el.length < 3) {
- throw new RuntimeException(new NetconfException("Invalid resource id, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid resource id, cannot apply"));
}
if (!el[2].contains((ResourceIdParser.KEY_SEP))) {
- throw new RuntimeException(new NetconfException("Invalid device id key, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id key, cannot apply"));
}
String[] keys = el[2].split(ResourceIdParser.KEY_CHK);
if (keys.length < 2) {
- throw new RuntimeException(new NetconfException("Invalid device id key, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id key, cannot apply"));
}
String[] parts = keys[1].split(ResourceIdParser.NM_CHK);
if (parts.length < 3) {
- throw new RuntimeException(new NetconfException("Invalid device id key, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id key, cannot apply"));
}
String[] temp = parts[2].split("\\:");
String ip, port;
if (temp.length != 3) {
- throw new RuntimeException(new NetconfException("Invalid device id form, cannot apply"));
+ throw new IllegalStateException(new NetconfException("Invalid device id form, cannot apply"));
}
ip = temp[1];
port = temp[2];
diff --git a/apps/p4-tutorial/pipeconf/src/main/java/org/onosproject/p4tutorial/pipeconf/PipeconfFactory.java b/apps/p4-tutorial/pipeconf/src/main/java/org/onosproject/p4tutorial/pipeconf/PipeconfFactory.java
index a1e65aa..5d37bd1 100644
--- a/apps/p4-tutorial/pipeconf/src/main/java/org/onosproject/p4tutorial/pipeconf/PipeconfFactory.java
+++ b/apps/p4-tutorial/pipeconf/src/main/java/org/onosproject/p4tutorial/pipeconf/PipeconfFactory.java
@@ -67,7 +67,7 @@
try {
pipelineModel = P4InfoParser.parse(P4INFO_URL);
} catch (P4InfoParserException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
return DefaultPiPipeconf.builder()
diff --git a/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MQServiceImpl.java b/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MQServiceImpl.java
index 11b46fb..2ecc5d2 100644
--- a/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MQServiceImpl.java
+++ b/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MQServiceImpl.java
@@ -91,7 +91,7 @@
prop.getProperty(SENDER_QUEUE)),
msgOutQueue);
} catch (Exception e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
manageSender.start();
}
diff --git a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/protocol/RouteAttributeDst.java b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/protocol/RouteAttributeDst.java
index 1535100..2962c0b 100644
--- a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/protocol/RouteAttributeDst.java
+++ b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/protocol/RouteAttributeDst.java
@@ -102,7 +102,7 @@
RouteAttribute.ROUTE_ATTRIBUTE_HEADER_LENGTH) {
cb.writeBytes(buffer, Ip4Address.BYTE_LENGTH);
} else {
- throw new RuntimeException("Dst address length incorrect!");
+ throw new IllegalArgumentException("Dst address length incorrect!");
}
}
}
diff --git a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/protocol/RouteAttributeGateway.java b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/protocol/RouteAttributeGateway.java
index 886f52e..3b1f5cd 100644
--- a/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/protocol/RouteAttributeGateway.java
+++ b/apps/routing/fpm/app/src/main/java/org/onosproject/routing/fpm/protocol/RouteAttributeGateway.java
@@ -104,7 +104,7 @@
RouteAttribute.ROUTE_ATTRIBUTE_HEADER_LENGTH) {
cb.writeBytes(buffer, Ip4Address.BYTE_LENGTH);
} else {
- throw new RuntimeException("Gateway address length incorrect!");
+ throw new IllegalArgumentException("Gateway address length incorrect!");
}
}
}
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java
index e958765..c510647 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/FloatingIpWebResource.java
@@ -193,10 +193,8 @@
*
* @param floatingIpNodes the floatingIp json node
* @return floatingIps a collection of floatingIp
- * @throws Exception when any argument is illegal
*/
- public Collection<FloatingIp> changeJsonToSub(JsonNode floatingIpNodes)
- throws Exception {
+ public Collection<FloatingIp> changeJsonToSub(JsonNode floatingIpNodes) {
checkNotNull(floatingIpNodes, JSON_NOT_NULL);
Map<FloatingIpId, FloatingIp> subMap = new HashMap<FloatingIpId, FloatingIp>();
if (!floatingIpNodes.hasNonNull("id")) {
diff --git a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
index c09b5cd..0d32a8d 100644
--- a/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
+++ b/apps/vtn/vtnweb/src/main/java/org/onosproject/vtnweb/resources/RouterWebResource.java
@@ -131,7 +131,7 @@
}
return Response.status(CREATED).entity(result.toString()).build();
- } catch (Exception e) {
+ } catch (IllegalArgumentException | IOException e) {
return Response.status(BAD_REQUEST).entity(e.getMessage()).build();
}
}
@@ -271,8 +271,7 @@
}
}
- private Collection<Router> createOrUpdateByInputStream(JsonNode subnode)
- throws Exception {
+ private Collection<Router> createOrUpdateByInputStream(JsonNode subnode) {
checkNotNull(subnode, JSON_NOT_NULL);
JsonNode routerNode = subnode.get("routers");
if (routerNode == null) {
@@ -281,7 +280,7 @@
log.debug("routerNode is {}", routerNode.toString());
if (routerNode.isArray()) {
- throw new Exception("only singleton requests allowed");
+ throw new IllegalArgumentException("only singleton requests allowed");
} else {
return changeJsonToSub(routerNode);
}
@@ -292,10 +291,8 @@
*
* @param routerNode the router json node
* @return routers a collection of router
- * @throws Exception when any argument is illegal
*/
- public Collection<Router> changeJsonToSub(JsonNode routerNode)
- throws Exception {
+ public Collection<Router> changeJsonToSub(JsonNode routerNode) {
checkNotNull(routerNode, JSON_NOT_NULL);
Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
if (!routerNode.hasNonNull("id")) {
@@ -361,11 +358,9 @@
* @param subnode the router json node
* @param routerId the router identify
* @return routers a collection of router
- * @throws Exception when any argument is illegal
*/
public Collection<Router> changeUpdateJsonToSub(JsonNode subnode,
- String routerId)
- throws Exception {
+ String routerId) {
checkNotNull(subnode, JSON_NOT_NULL);
checkNotNull(routerId, "routerId should not be null");
Map<RouterId, Router> subMap = new HashMap<RouterId, Router>();
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();
diff --git a/drivers/cisco/netconf/src/main/java/org/onosproject/drivers/cisco/CiscoIosDeviceDescription.java b/drivers/cisco/netconf/src/main/java/org/onosproject/drivers/cisco/CiscoIosDeviceDescription.java
index 8839c59..d52c470 100644
--- a/drivers/cisco/netconf/src/main/java/org/onosproject/drivers/cisco/CiscoIosDeviceDescription.java
+++ b/drivers/cisco/netconf/src/main/java/org/onosproject/drivers/cisco/CiscoIosDeviceDescription.java
@@ -49,7 +49,7 @@
try {
version = session.get(showVersionRequestBuilder());
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to retrieve version info.", e));
+ throw new IllegalStateException(new NetconfException("Failed to retrieve version info.", e));
}
String[] details = TextBlockParserCisco.parseCiscoIosDeviceDetails(version);
diff --git a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/FlowRuleJuniperImpl.java b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/FlowRuleJuniperImpl.java
index d4c09dc..cb07843 100644
--- a/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/FlowRuleJuniperImpl.java
+++ b/drivers/juniper/src/main/java/org/onosproject/drivers/juniper/FlowRuleJuniperImpl.java
@@ -100,7 +100,7 @@
try {
reply = session.get(routingTableBuilder());
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to retrieve configuration.",
+ throw new IllegalStateException(new NetconfException("Failed to retrieve configuration.",
e));
}
Collection<StaticRoute> devicesStaticRoutes =
@@ -241,7 +241,7 @@
}
}
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to retrieve configuration.",
+ throw new IllegalStateException(new NetconfException("Failed to retrieve configuration.",
e));
}
return false;
@@ -335,7 +335,7 @@
try {
replay = session.get(commitBuilder());
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to retrieve configuration.",
+ throw new IllegalStateException(new NetconfException("Failed to retrieve configuration.",
e));
}
@@ -355,7 +355,7 @@
try {
replay = session.get(rollbackBuilder(0));
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to retrieve configuration.",
+ throw new IllegalStateException(new NetconfException("Failed to retrieve configuration.",
e));
}
diff --git a/drivers/oplink/src/main/java/org/onosproject/drivers/oplink/OplinkNetconfUtility.java b/drivers/oplink/src/main/java/org/onosproject/drivers/oplink/OplinkNetconfUtility.java
index 966821e..4662219 100644
--- a/drivers/oplink/src/main/java/org/onosproject/drivers/oplink/OplinkNetconfUtility.java
+++ b/drivers/oplink/src/main/java/org/onosproject/drivers/oplink/OplinkNetconfUtility.java
@@ -69,7 +69,7 @@
try {
reply = session.get(filter, null);
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to retrieve configuration.", e));
+ throw new IllegalStateException(new NetconfException("Failed to retrieve configuration.", e));
}
return reply;
}
@@ -88,7 +88,7 @@
try {
reply = session.getConfig(DatastoreId.RUNNING, filter);
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to retrieve configuration.", e));
+ throw new IllegalStateException(new NetconfException("Failed to retrieve configuration.", e));
}
return reply;
}
@@ -108,7 +108,7 @@
try {
reply = session.editConfig(DatastoreId.RUNNING, mode, cfg);
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to edit configuration.", e));
+ throw new IllegalStateException(new NetconfException("Failed to edit configuration.", e));
}
return reply;
}
diff --git a/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisNetconfUtility.java b/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisNetconfUtility.java
index 6b8080b..1cb8031 100644
--- a/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisNetconfUtility.java
+++ b/drivers/polatis/netconf/src/main/java/org/onosproject/drivers/polatis/netconf/PolatisNetconfUtility.java
@@ -82,7 +82,7 @@
try {
reply = session.get(filter, null);
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to retrieve configuration.", e));
+ throw new IllegalStateException(new NetconfException("Failed to retrieve configuration.", e));
}
return reply;
}
@@ -100,7 +100,7 @@
try {
reply = session.getConfig(DatastoreId.RUNNING, filter);
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to retrieve configuration.", e));
+ throw new IllegalStateException(new NetconfException("Failed to retrieve configuration.", e));
}
return reply;
}
@@ -119,7 +119,7 @@
try {
reply = session.editConfig(DatastoreId.RUNNING, mode, cfg);
} catch (NetconfException e) {
- throw new RuntimeException(new NetconfException("Failed to edit configuration.", e));
+ throw new IllegalStateException(new NetconfException("Failed to edit configuration.", e));
}
return reply;
}
@@ -223,7 +223,7 @@
NetconfController controller = checkNotNull(handler.get(NetconfController.class));
NetconfSession session = controller.getNetconfDevice(handler.data().deviceId()).getSession();
if (session == null) {
- throw new RuntimeException(new NetconfException("Failed to retrieve the netconf device."));
+ throw new IllegalStateException(new NetconfException("Failed to retrieve the netconf device."));
}
return session;
}
diff --git a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java
index 1a5d4d2..8b5bf60 100644
--- a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java
+++ b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java
@@ -112,7 +112,7 @@
try {
return P4InfoParser.parse(p4InfoUrl);
} catch (P4InfoParserException e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
}
diff --git a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java
index e9a1f64..acd1c7b 100644
--- a/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java
+++ b/protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/Controller.java
@@ -129,7 +129,7 @@
cg.add(serverChannel);
log.info("Listening for Peer connection on {}", sa);
} catch (Exception e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
index 6deadfd..e8dc9f0 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/Controller.java
@@ -206,7 +206,7 @@
* @param json posted json
* @return list of processes configured
*/
- private List<IsisProcess> getConfig(JsonNode json) throws Exception {
+ private List<IsisProcess> getConfig(JsonNode json) {
List<IsisProcess> isisProcessesList = new ArrayList<>();
JsonNode jsonNodes = json;
if (jsonNodes == null) {
diff --git a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
index a43f424..ddee647 100644
--- a/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
+++ b/protocols/isis/ctl/src/main/java/org/onosproject/isis/controller/impl/lsdb/IsisLspQueueConsumer.java
@@ -82,7 +82,7 @@
*
* @param wrapper LSP wrapper instance
*/
- private void processRefreshLsp(LspWrapper wrapper) throws Exception {
+ private void processRefreshLsp(LspWrapper wrapper) {
if (wrapper.isSelfOriginated()) { //self originated
DefaultIsisInterface isisInterface = (DefaultIsisInterface) wrapper.isisInterface();
Channel channel = isisInterface.channel();
diff --git a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisMessageReader.java b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisMessageReader.java
index c1d5f81..09cac03 100644
--- a/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisMessageReader.java
+++ b/protocols/isis/isisio/src/main/java/org/onosproject/isis/io/isispacket/IsisMessageReader.java
@@ -105,7 +105,7 @@
* @return ISIS header
* @throws Exception
*/
- private IsisHeader getIsisHeader(ChannelBuffer channelBuffer) throws Exception {
+ private IsisHeader getIsisHeader(ChannelBuffer channelBuffer) {
IsisHeader isisHeader = new IsisHeader();
isisHeader.setIrpDiscriminator(channelBuffer.readByte());
diff --git a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/LispControllerBootstrap.java b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/LispControllerBootstrap.java
index 9b05097..8e6bcf9 100644
--- a/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/LispControllerBootstrap.java
+++ b/protocols/lisp/ctl/src/main/java/org/onosproject/lisp/ctl/impl/LispControllerBootstrap.java
@@ -70,8 +70,8 @@
f.sync();
}
- } catch (Exception e) {
- throw new RuntimeException(e);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
}
}
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/authentication/LispMacAuthentication.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/authentication/LispMacAuthentication.java
index a6af0b6..20a2f2a 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/authentication/LispMacAuthentication.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/authentication/LispMacAuthentication.java
@@ -75,10 +75,10 @@
return mac.doFinal(data);
} catch (NoSuchAlgorithmException e) {
log.warn(NOT_SUPPORT_ALGORITHM_MSG, algorithm, e.getMessage());
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
} catch (InvalidKeyException e) {
log.warn(INVALID_KEY_MSG, key, e.getMessage());
- throw new RuntimeException(e);
+ throw new IllegalArgumentException(e);
}
}
}
diff --git a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamThread.java b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamThread.java
index a11af4e..e80e214 100644
--- a/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamThread.java
+++ b/protocols/netconf/ctl/src/main/java/org/onosproject/netconf/ctl/impl/NetconfStreamThread.java
@@ -293,7 +293,7 @@
}
} catch (IOException e) {
log.warn("Error in reading from the session for device {} ", netconfDeviceInfo, e);
- throw new RuntimeException(new NetconfException("Error in reading from the session for device {}" +
+ throw new IllegalStateException(new NetconfException("Error in reading from the session for device {}" +
netconfDeviceInfo, e));
//TODO should we send a socket closed message to listeners ?
}
diff --git a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java
index 99f47f8..578dae0 100644
--- a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java
+++ b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/Controller.java
@@ -18,7 +18,6 @@
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
-
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
@@ -29,7 +28,6 @@
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.util.concurrent.GlobalEventExecutor;
-
import org.onlab.util.ItemNotFoundException;
import org.onosproject.net.DeviceId;
import org.onosproject.net.driver.DefaultDriverData;
@@ -50,9 +48,15 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManagerFactory;
import java.io.FileInputStream;
+import java.io.IOException;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
+import java.security.KeyManagementException;
import java.security.KeyStore;
+import java.security.KeyStoreException;
+import java.security.NoSuchAlgorithmException;
+import java.security.UnrecoverableKeyException;
+import java.security.cert.CertificateException;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.List;
@@ -147,7 +151,6 @@
*/
public void run() {
- try {
final ServerBootstrap bootstrap = createServerBootStrap();
bootstrap.option(ChannelOption.SO_REUSEADDR, true);
bootstrap.childOption(ChannelOption.SO_KEEPALIVE, true);
@@ -164,10 +167,6 @@
log.info("Listening for switch connections on {}", port);
});
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
}
private ServerBootstrap createServerBootStrap() {
@@ -236,13 +235,9 @@
cg = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
- try {
- getTlsParameters();
- if (enableOfTls) {
- initSsl();
- }
- } catch (Exception ex) {
- log.error("SSL init failed: {}", ex.getMessage());
+ getTlsParameters();
+ if (enableOfTls) {
+ initSsl();
}
}
@@ -274,19 +269,24 @@
}
}
- private void initSsl() throws Exception {
- TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
- KeyStore ts = KeyStore.getInstance("JKS");
- ts.load(new FileInputStream(tsLocation), tsPwd);
- tmFactory.init(ts);
+ private void initSsl() {
+ try {
+ TrustManagerFactory tmFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ KeyStore ts = KeyStore.getInstance("JKS");
+ ts.load(new FileInputStream(tsLocation), tsPwd);
+ tmFactory.init(ts);
- KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
- KeyStore ks = KeyStore.getInstance("JKS");
- ks.load(new FileInputStream(ksLocation), ksPwd);
- kmf.init(ks, ksPwd);
+ KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
+ KeyStore ks = KeyStore.getInstance("JKS");
+ ks.load(new FileInputStream(ksLocation), ksPwd);
+ kmf.init(ks, ksPwd);
- sslContext = SSLContext.getInstance("TLS");
- sslContext.init(kmf.getKeyManagers(), tmFactory.getTrustManagers(), null);
+ sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(kmf.getKeyManagers(), tmFactory.getTrustManagers(), null);
+ } catch (NoSuchAlgorithmException | KeyStoreException | CertificateException |
+ IOException | KeyManagementException | UnrecoverableKeyException ex) {
+ log.error("SSL init failed: {}", ex.getMessage());
+ }
}
// **************
diff --git a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java
index 414bd89..a9455b6 100644
--- a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java
+++ b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFChannelHandler.java
@@ -1357,9 +1357,9 @@
return getSwitchInfoString();
}
- protected void channelIdle(ChannelHandlerContext ctx,
+ private void channelIdle(ChannelHandlerContext ctx,
IdleStateEvent e)
- throws Exception {
+ throws IOException {
OFMessage m = factory.buildEchoRequest().build();
log.debug("Sending Echo Request on idle channel: {}",
ctx.channel());
diff --git a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java
index 4c875ac..c541a9b 100644
--- a/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java
+++ b/protocols/openflow/ctl/src/main/java/org/onosproject/openflow/controller/impl/OFMessageEncoder.java
@@ -56,7 +56,7 @@
@Override
public void write(ChannelHandlerContext ctx,
Object msg,
- ChannelPromise promise) throws Exception {
+ ChannelPromise promise) {
ByteBuf buf = null;
try {
diff --git a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
index f4e8255..a66160d 100644
--- a/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
+++ b/protocols/ospf/api/src/main/java/org/onosproject/ospf/controller/OspfArea.java
@@ -16,7 +16,6 @@
package org.onosproject.ospf.controller;
import org.onlab.packet.Ip4Address;
-import org.onosproject.ospf.exceptions.OspfParseException;
import java.util.List;
@@ -200,9 +199,8 @@
*
* @param ospfLsa LSA instance
* @param ospfInterface interface instance
- * @throws OspfParseException might throws exception
*/
- void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface) throws OspfParseException;
+ void addLsa(OspfLsa ospfLsa, OspfInterface ospfInterface);
/**
* Sets router sequence number for router LSA.
diff --git a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/Controller.java b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/Controller.java
index c85e22a..f7f596c 100644
--- a/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/Controller.java
+++ b/protocols/pcep/server/ctl/src/main/java/org/onosproject/pcep/server/impl/Controller.java
@@ -205,7 +205,7 @@
cg.add(bootstrap.bind(sa));
log.debug("Listening for PCC connection on {}", sa);
} catch (Exception e) {
- throw new RuntimeException(e);
+ throw new IllegalStateException(e);
}
}
diff --git a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
index c35682c..99c8ebd 100644
--- a/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
+++ b/providers/netconf/device/src/main/java/org/onosproject/provider/netconf/device/impl/NetconfDeviceProvider.java
@@ -582,7 +582,7 @@
providerService.deviceDisconnected(deviceId);
}
deviceKeyAdminService.removeKey(DeviceKeyId.deviceKeyId(deviceId.toString()));
- throw new RuntimeException(new NetconfException(
+ throw new IllegalStateException(new NetconfException(
"Can't connect to NETCONF device " + deviceId, e));
}
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index b489c52..66ded21 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -1004,7 +1004,7 @@
sigType = CltSignalType.CLT_100GBE;
break;
default:
- throw new RuntimeException("Un recognize OduClt speed: " + portSpeedInMbps.toString());
+ throw new IllegalArgumentException("Un recognize OduClt speed: " + portSpeedInMbps.toString());
}
SparseAnnotations annotations = buildOduCltAnnotation(port);
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceValueMapper.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceValueMapper.java
index 28ebb3c..789e7e5 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceValueMapper.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceValueMapper.java
@@ -51,7 +51,7 @@
*/
private static <I, O> O lookup(BiMap<I, O> map, I input, Class<O> cls) {
if (!map.containsKey(input)) {
- throw new RuntimeException(
+ throw new IllegalArgumentException(
String.format("No mapping found for %s when converting to %s", input, cls.getName()));
}
diff --git a/providers/openflow/message/src/main/java/org/onosproject/provider/of/message/impl/OpenFlowControlMessageMapper.java b/providers/openflow/message/src/main/java/org/onosproject/provider/of/message/impl/OpenFlowControlMessageMapper.java
index 582484d..5b73e0f 100644
--- a/providers/openflow/message/src/main/java/org/onosproject/provider/of/message/impl/OpenFlowControlMessageMapper.java
+++ b/providers/openflow/message/src/main/java/org/onosproject/provider/of/message/impl/OpenFlowControlMessageMapper.java
@@ -59,7 +59,7 @@
*/
private static <I, O> O lookup(BiMap<I, O> map, I input, Class<O> cls) {
if (!map.containsKey(input)) {
- throw new RuntimeException(
+ throw new IllegalArgumentException(
String.format("No mapping found for %s when converting to %s",
input, cls.getName()));
}
diff --git a/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6ClientIdOption.java b/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6ClientIdOption.java
index 5623e71..f4f3fc8 100644
--- a/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6ClientIdOption.java
+++ b/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6ClientIdOption.java
@@ -49,7 +49,7 @@
Dhcp6Duid duid = Dhcp6Duid.deserializer().deserialize(data, 0, data.length);
this.setDuid(duid);
} catch (DeserializationException e) {
- throw new RuntimeException("Invalid DUID");
+ throw new IllegalArgumentException("Invalid DUID");
}
}
diff --git a/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6Duid.java b/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6Duid.java
index c8ca3bd..80675e2 100644
--- a/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6Duid.java
+++ b/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6Duid.java
@@ -51,7 +51,7 @@
case 3:
return DUID_LL;
default:
- throw new RuntimeException("Unknown type: " + type);
+ throw new IllegalArgumentException("Unknown type: " + type);
}
}
}
@@ -139,7 +139,7 @@
byteBuffer.put(linkLayerAddress);
break;
default:
- throw new RuntimeException("Unknown duidType: " + duidType.toString());
+ throw new IllegalArgumentException("Unknown duidType: " + duidType.toString());
}
return byteBuffer.array();
}
@@ -171,7 +171,7 @@
byteBuffer.get(duid.linkLayerAddress);
break;
default:
- throw new RuntimeException("Unknown type: " + duidType);
+ throw new IllegalArgumentException("Unknown type: " + duidType);
}
return duid;
};
diff --git a/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6Option.java b/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6Option.java
index f19f735..8202b30 100644
--- a/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6Option.java
+++ b/utils/misc/src/main/java/org/onlab/packet/dhcp/Dhcp6Option.java
@@ -74,7 +74,7 @@
try {
this.payload = Data.deserializer().deserialize(data, 0, data.length);
} catch (DeserializationException e) {
- throw new RuntimeException("Invalid data");
+ throw new IllegalArgumentException("Invalid data");
}
}
diff --git a/utils/misc/src/main/java/org/onlab/util/Tools.java b/utils/misc/src/main/java/org/onlab/util/Tools.java
index bf9bea0..4b2cac9 100644
--- a/utils/misc/src/main/java/org/onlab/util/Tools.java
+++ b/utils/misc/src/main/java/org/onlab/util/Tools.java
@@ -388,7 +388,7 @@
try {
Thread.sleep(ms);
} catch (InterruptedException e) {
- throw new RuntimeException("Interrupted", e);
+ throw new IllegalStateException("Interrupted", e);
}
}
@@ -460,7 +460,7 @@
try {
Thread.sleep(random.nextInt(ms));
} catch (InterruptedException e) {
- throw new RuntimeException("Interrupted", e);
+ throw new IllegalStateException("Interrupted", e);
}
}
@@ -474,7 +474,7 @@
try {
Thread.sleep(ms, nanos);
} catch (InterruptedException e) {
- throw new RuntimeException("Interrupted", e);
+ throw new IllegalStateException("Interrupted", e);
}
}