Cleanup RuntimeException throws 15/81015/2
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 19 Mar 2019 17:04:49 +0000 (18:04 +0100)
committerJie Han <han.jie@zte.com.cn>
Wed, 20 Mar 2019 02:12:35 +0000 (02:12 +0000)
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>
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 0052990d1c2f725a23d46949fcbca23f9b8765a0..471d6d13786fc9b6ec42ff0e3937ee73a05a4b8f 100644 (file)
@@ -107,7 +107,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 ab1f3a87cce27ce045ae0781df96e1f8402f4f55..b1a073eb5322f3eff0f070806df42efa56c1ae34 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 b4aed692f9b195bb1c1652cfc6fdcf940be841f8..3dcc386bd2d48ba5ca5e49369f53274a3e55c2d2 100644 (file)
@@ -538,7 +538,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 560e7332526b614f0a03be476800c8b5daee324b..5e9f21e89e38bbb1880fef136d46fdd0009d78ca 100644 (file)
@@ -40,7 +40,7 @@ final class EncapsulatedValueCodec extends ReflectionBasedCodec implements Schem
         this.valueType = requireNonNull(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) {
@@ -74,7 +74,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);
         }
     }
 
@@ -85,7 +85,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 6143f08ef59262eeb9bdd5c84e45e2676a2aecb2..ea78e8b17c79fd332441ae26ed52165a5e6182b2 100644 (file)
@@ -84,7 +84,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 06af2a195f2f62e23035d01bff10a3ae93520674..02f6ac8195af94d40143254f3cbbebd75ad157c9 100644 (file)
@@ -147,7 +147,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 d2f96f76986057b39264483654ec515c7977942e..3fc183ee34b35da2453c72702ebfe4423a341d10 100644 (file)
@@ -250,7 +250,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 do not need since this listener doesn't have to be registered at the root of the DataTree