SONAR suggestion - generic exceptions
Replace uses of generic RuntimeException
with more appropriate unchecked exceptions
Change-Id: If283743c2cf7252b8d280bdb788708ebbe57da9d
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()));
}
}
}