Cleanup RuntimeException throws 75/81075/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 19 Mar 2019 17:04:49 +0000 (18:04 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 21 Mar 2019 12:24:38 +0000 (13:24 +0100)
We are just wrapping exceptions in these cases, switch to wrapping
with IllegalStateException to keep sonar happy.

Change-Id: I571f444b9d97dd9d9129b6e18f7e91e72b30d842
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit fda572130077da8029e12bb770b0b8c8fb7890d0)

14 files changed:
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/DirectGetterRouteContextExtractor.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/FutureSchema.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/GetValueRouteContextExtractor.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/NotificationListenerInvoker.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/RpcMethodInvokerWithInput.java
binding/mdsal-binding-dom-adapter/src/main/java/org/opendaylight/mdsal/binding/dom/adapter/invoke/RpcMethodInvokerWithoutInput.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/CachingNormalizedNodeSerializer.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/DataObjectCodecContext.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/EncapsulatedValueCodec.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/IdentifiableItemCodec.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/UnionValueOptionContext.java
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/ValueContext.java
binding/mdsal-binding-spec-util/src/main/java/org/opendaylight/mdsal/binding/spec/reflect/StringValueObjectFactory.java
dom/mdsal-dom-inmemory-datastore/src/main/java/org/opendaylight/mdsal/dom/store/inmemory/AbstractDOMShardTreeChangePublisher.java

index 96536bff864c42b64d4056d74e2f27130091fc00..35631753035ab0e3baa03e993cc7ca2be3014513 100644 (file)
@@ -38,7 +38,7 @@ final class DirectGetterRouteContextExtractor extends ContextReferenceExtractor
             return (InstanceIdentifier<?>) handle.invokeExact(obj);
         } catch (final Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 }
index 0511c4a99aeca46b82c7d1f83ec25d0fee24c70e..b89f7f406d702e10ec2d281d23d4f9c22a009d37 100644 (file)
@@ -50,7 +50,7 @@ abstract class FutureSchema implements AutoCloseable {
                 schemaPromise.get(FutureSchema.this.duration, FutureSchema.this.unit);
                 return true;
             } catch (final InterruptedException | ExecutionException e) {
-                throw new RuntimeException(e);
+                throw new IllegalStateException(e);
             } catch (final TimeoutException e) {
                 return false;
             } finally {
index 1879b16f100c045c7fb500430381f9b216dddd4c..208d9f65bb6ccd61d06d52fcb9689eae75fd41e9 100644 (file)
@@ -46,7 +46,7 @@ final class GetValueRouteContextExtractor extends ContextReferenceExtractor {
             return null;
         } catch (final Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 }
index 5c5dd1dd1c6b3c8155889aed81ac760c335af81d..749476a25e6f9f9e207a968b5f1b5b27ea1bcd06 100644 (file)
@@ -105,7 +105,7 @@ public final class NotificationListenerInvoker {
             invoker.invokeExact(impl, input);
         } catch (final Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 }
index eceaaa68d00b538d748067717a5637813959205c..cb85e00b5aa2b040dbc30a6b87c748d1b6baebb5 100644 (file)
@@ -32,7 +32,7 @@ class RpcMethodInvokerWithInput extends RpcMethodInvoker {
             return (ListenableFuture<RpcResult<?>>) handle.invokeExact(impl,input);
         } catch (Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 }
\ No newline at end of file
index 03bc92cee6bbeaecd13bc4c3fd7266cebff1fc70..cb5c001302a40193d696c645555831e5b2b70375 100644 (file)
@@ -32,7 +32,7 @@ class RpcMethodInvokerWithoutInput extends RpcMethodInvoker {
             return (ListenableFuture<RpcResult<?>>) handle.invokeExact(impl);
         } catch (Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 }
\ No newline at end of file
index d8f08d96b71bea022a01e756e0c286fcc307e823..7f0e3dc56a5ab0d64e48b7f8b538233d06da236b 100644 (file)
@@ -120,7 +120,7 @@ final class CachingNormalizedNodeSerializer extends ForwardingBindingStreamEvent
             subtreeRoot.eventStreamSerializer().serialize(data, writer);
             return writer.build();
         } catch (final IOException e) {
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 }
\ No newline at end of file
index e1004241e0ae901512fa535aad891bc5f4c1b1f0..261e5d2677b3f3fcffdd8eef91242e0f0d8c5a10 100644 (file)
@@ -510,7 +510,7 @@ abstract class DataObjectCodecContext<D extends DataObject, T extends DataNodeCo
             return (D) proxyConstructor.invokeExact((InvocationHandler)new LazyDataObject<>(this, node));
         } catch (final Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
index 95e43f688c6a01c1a2284bd5b108617a1fa16c3e..0c7f0c3886be643418179dfbe0222e6ab9f7ebb6 100644 (file)
@@ -39,7 +39,7 @@ final class EncapsulatedValueCodec extends ReflectionBasedCodec implements Schem
         this.valueType = Preconditions.checkNotNull(valueType);
     }
 
-    static Callable<EncapsulatedValueCodec> loader(final Class<?> typeClz, TypeDefinition<?> typeDef) {
+    static Callable<EncapsulatedValueCodec> loader(final Class<?> typeClz, final TypeDefinition<?> typeDef) {
         return () -> {
             final Method m;
             if (typeDef instanceof BooleanTypeDefinition || typeDef instanceof EmptyTypeDefinition) {
@@ -73,7 +73,7 @@ final class EncapsulatedValueCodec extends ReflectionBasedCodec implements Schem
             return constructor.invokeExact(input);
         } catch (Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
@@ -84,7 +84,7 @@ final class EncapsulatedValueCodec extends ReflectionBasedCodec implements Schem
             return getter.invokeExact(input);
         } catch (Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 }
\ No newline at end of file
index 0b38fef314919ed43728b17dfc7321c94977d600..6c90da7643d54b03ec12412921da7a8801b8c637 100644 (file)
@@ -149,7 +149,7 @@ abstract class IdentifiableItemCodec implements Codec<NodeIdentifierWithPredicat
             identifier = deserializeIdentifier(input.getKeyValues());
         } catch (Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException("Failed to deserialize " + input, e);
         }
 
         return IdentifiableItem.of((Class) identifiable, (Identifier) identifier);
@@ -173,7 +173,7 @@ abstract class IdentifiableItemCodec implements Codec<NodeIdentifierWithPredicat
                 try {
                     return MethodHandles.publicLookup().unreflectConstructor(constr);
                 } catch (IllegalAccessException e) {
-                    throw new IllegalArgumentException("Cannot access constructor " + constr + " in class " + clazz, e);
+                    throw new IllegalStateException("Cannot access constructor " + constr + " in class " + clazz, e);
                 }
             }
         }
index 5b1ae9eeb1b4f4c1fdd0321d7d7858d1705914f1..e050f9647c84a0905ef8c5116b7314e568ad4cdf 100644 (file)
@@ -83,7 +83,7 @@ final class UnionValueOptionContext {
             return getter.invokeExact(input);
         } catch (Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
     }
 
index 9c2ae02c397c529adad2aace2ef780c6638fc64b..bc621f1212400cc0285e0a971da5a9f7ddf028cc 100644 (file)
@@ -40,7 +40,7 @@ final class ValueContext {
             value = getter.invokeExact(obj);
         } catch (Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException(e);
         }
 
         Preconditions.checkArgument(value != null,
index 41328d5469d911cdde396c8c5caabf73b79f7e17..c2ae37ab30e54c00d4281d0f694b0683fc3c3fd8 100644 (file)
@@ -139,7 +139,7 @@ public final class StringValueObjectFactory<T> {
             return ret;
         } catch (Throwable e) {
             Throwables.throwIfUnchecked(e);
-            throw new RuntimeException(e);
+            throw new IllegalStateException("Failed to instantiate object with value " + string, e);
         }
     }
 
index 644e7d368c461918b7ea3a43d8ddbb616ea8a033..16290ad0661c7ffecbaf8f8065fcde8e32231718 100644 (file)
@@ -254,7 +254,7 @@ abstract class AbstractDOMShardTreeChangePublisher extends AbstractDOMStoreTreeC
                 dataTree.validate(modification);
             } catch (final DataValidationFailedException e) {
                 LOG.error("Validation failed for built modification", e);
-                throw new RuntimeException("Notification validation failed", e);
+                throw new IllegalStateException("Notification validation failed", e);
             }
 
             // strip nodes we dont need since this listener doesn't have to be registered at the root of the DataTree