BUG-731: use IllegalArgumentException 95/6195/1
authorRobert Varga <rovarga@cisco.com>
Tue, 15 Apr 2014 07:08:02 +0000 (09:08 +0200)
committerRobert Varga <rovarga@cisco.com>
Tue, 15 Apr 2014 07:23:11 +0000 (09:23 +0200)
This gets rid of non-descriptive RuntimeException in favor of
IllegalArgumentException.

Change-Id: Idd4f3452eb0a2b2ea7235fdfe5545490209e9993
Signed-off-by: Robert Varga <rovarga@cisco.com>
bgp/util/src/main/java/org/opendaylight/protocol/bgp/util/HexDumpBGPFileParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiator.java

index 82a6515975e1e0d19560595fa60e934f72b9e03a..ecb1e41087d6d0bdd288596fd9bccc9daee18556 100644 (file)
@@ -72,7 +72,7 @@ public final class HexDumpBGPFileParser {
                        try {
                                byteLength = Hex.decodeHex(hexLength.toCharArray());
                        } catch (final DecoderException e) {
-                               throw new RuntimeException(e);
+                               throw new IllegalArgumentException("Failed to decode message length", e);
                        }
                        final int length = ByteArray.bytesToInt(byteLength);
                        final int messageEndIdx = idx + length * 2;
@@ -87,7 +87,7 @@ public final class HexDumpBGPFileParser {
                        try {
                                message = Hex.decodeHex(hexMessage.toCharArray());
                        } catch (final DecoderException e) {
-                               new RuntimeException(e);
+                               new IllegalArgumentException("Failed to decode message body", e);
                        }
                        messages.add(message);
                        idx = messageEndIdx;
index bbaa82f8669f941b18a1c826bcaba22f915c86a5..dda8688c99aa9b4152f767dfc22f4fd5027a6ec0 100644 (file)
@@ -100,14 +100,14 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
 
        /**
         * Get the initial session parameters proposal.
-        * 
+        *
         * @return Session parameters proposal.
         */
        protected abstract Open getInitialProposal();
 
        /**
         * Get the revised session parameters proposal based on the feedback the peer has provided to us.
-        * 
+        *
         * @param suggestion Peer-provided suggested session parameters
         * @return Session parameters proposal, or null if peers session parameters preclude us from suggesting anything
         */
@@ -115,7 +115,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
 
        /**
         * Check whether a peer-provided session parameters proposal is acceptable.
-        * 
+        *
         * @param proposal peer-proposed session parameters
         * @return true if the proposal is acceptable, false otherwise
         */
@@ -124,7 +124,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
        /**
         * Given a peer-provided session parameters proposal which we found unacceptable, provide a counter-proposal. The
         * requirement is that the isProposalAcceptable() method has to return true when presented with this proposal.
-        * 
+        *
         * @param proposal unacceptable peer proposal
         * @return our counter-proposal, or null if there is no way to negotiate an acceptable proposal
         */
@@ -132,7 +132,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
 
        /**
         * Create the protocol session.
-        * 
+        *
         * @param timer Timer which the session can use for its various functions.
         * @param channel Underlying channel.
         * @param sessionId Assigned session ID.
@@ -144,7 +144,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
 
        /**
         * Sends PCEP Error Message with one PCEPError.
-        * 
+        *
         * @param value
         */
        private void sendErrorMessage(final PCEPErrors value) {
@@ -225,14 +225,14 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
                                if (err.getErrorType() == null) {
                                        final ErrorObject obj = err.getErrors().get(0).getErrorObject();
                                        LOG.warn("Unexpected error received from PCC: type {} value {}", obj.getType(), obj.getValue());
-                                       negotiationFailed(new RuntimeException("Unexpected error received from PCC."));
+                                       negotiationFailed(new IllegalStateException("Unexpected error received from PCC."));
                                        this.state = State.Idle;
                                        return;
                                }
                                this.localPrefs = getRevisedProposal(((SessionCase) err.getErrorType()).getSession().getOpen());
                                if (this.localPrefs == null) {
                                        sendErrorMessage(PCEPErrors.PCERR_NON_ACC_SESSION_CHAR);
-                                       negotiationFailed(new RuntimeException("Peer suggested unacceptable retry proposal"));
+                                       negotiationFailed(new IllegalStateException("Peer suggested unacceptable retry proposal"));
                                        this.state = State.Finished;
                                        return;
                                }