SONAR suggestion - don't use generic exceptions

Change-Id: I77c4325281e94e189b7f1212a932f7e912b56b51
This commit is contained in:
Ray Milkey 2018-02-06 18:59:06 -08:00
parent 074ba9b90f
commit 2b4958a463
9 changed files with 11 additions and 16 deletions

View File

@ -26,8 +26,7 @@ import org.projectfloodlight.openflow.protocol.OFMessage;
public final class OFMessageEncoder extends MessageToByteEncoder<Iterable<OFMessage>> {
@Override
protected void encode(ChannelHandlerContext ctx, Iterable<OFMessage> msgList, ByteBuf out)
throws Exception {
protected void encode(ChannelHandlerContext ctx, Iterable<OFMessage> msgList, ByteBuf out) {
if (!ctx.channel().isActive()) {
return;
}

View File

@ -225,7 +225,7 @@ public final class MQUtil {
properties.load(is);
} catch (Exception e) {
log.error(ExceptionUtils.getFullStackTrace(e));
throw new RuntimeException(e);
throw new IllegalStateException(e);
}
return properties;
}

View File

@ -170,8 +170,7 @@ public class FloatingIpWebResource extends AbstractWebResource {
}
}
private Collection<FloatingIp> createOrUpdateByInputStream(JsonNode subnode)
throws Exception {
private Collection<FloatingIp> createOrUpdateByInputStream(JsonNode subnode) {
checkNotNull(subnode, JSON_NOT_NULL);
Collection<FloatingIp> floatingIps = null;
JsonNode floatingIpNodes = subnode.get("floatingips");

View File

@ -92,7 +92,7 @@ public class NetworkConfigCommand extends AbstractShellCommand {
try {
print("%s", mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root));
} catch (JsonProcessingException e) {
throw new RuntimeException("Error writing JSON to string", e);
throw new IllegalStateException("Error writing JSON to string", e);
}
}

View File

@ -143,7 +143,7 @@ public class PolatisFlowRuleProgrammable
private String parseKeyPairCompat() {
String rev = opticalRevision(handler());
if (rev == null) {
throw new RuntimeException(new NetconfException("Failed to obtain the revision."));
throw new IllegalStateException(new NetconfException("Failed to obtain the revision."));
}
String keyPairCompat;
try {
@ -156,7 +156,7 @@ public class PolatisFlowRuleProgrammable
keyPairCompat = KEY_PAIR;
}
} catch (ParseException e) {
throw new RuntimeException(new NetconfException(String.format("Incorrect date format: %s", rev)));
throw new IllegalArgumentException(new NetconfException(String.format("Incorrect date format: %s", rev)));
}
return keyPairCompat;
}

View File

@ -93,7 +93,7 @@ public class PipeconfLoader {
try {
return P4InfoParser.parse(p4InfoUrl);
} catch (P4InfoParserException e) {
throw new RuntimeException(e);
throw new IllegalStateException(e);
}
}
}

View File

@ -94,9 +94,8 @@ public class Controller {
* Updates the processes configuration.
*
* @param jsonNode json node instance
* @throws Exception might throws parse exception
*/
public void updateConfig(JsonNode jsonNode) throws Exception {
public void updateConfig(JsonNode jsonNode) {
log.debug("Controller::UpdateConfig called");
configPacket = new byte[IsisConstants.CONFIG_LENGTH];
byte numberOfInterface = 0; // number of interfaces to configure

View File

@ -236,9 +236,8 @@ public class IsisChannelHandler extends IdleStateAwareChannelHandler {
*
* @param isisMessage received ISIS message
* @param ctx channel handler context instance.
* @throws Exception might throws exception
*/
public void processIsisMessage(IsisMessage isisMessage, ChannelHandlerContext ctx) throws Exception {
public void processIsisMessage(IsisMessage isisMessage, ChannelHandlerContext ctx) {
log.debug("IsisChannelHandler::processIsisMessage...!!!");
int interfaceIndex = isisMessage.interfaceIndex();
IsisInterface isisInterface = isisInterfaceMap.get(interfaceIndex);

View File

@ -40,9 +40,9 @@ public class IsisMessageReader {
*
* @param channelBuffer buffer
* @return ISIS message
* @throws Exception exception
* @throws IsisParseException exception
*/
public IsisMessage readFromBuffer(ChannelBuffer channelBuffer) throws Exception {
public IsisMessage readFromBuffer(ChannelBuffer channelBuffer) throws IsisParseException {
int dataLength = channelBuffer.readableBytes();
log.debug("IsisMessageReader::readFromBuffer Data length {}", dataLength);
@ -103,7 +103,6 @@ public class IsisMessageReader {
*
* @param channelBuffer ISIS header
* @return ISIS header
* @throws Exception
*/
private IsisHeader getIsisHeader(ChannelBuffer channelBuffer) {