Cleanup DataBrokerTestModule error reporting 91/90091/1
authorRobert Varga <robert.varga@pantheon.tech>
Fri, 29 May 2020 12:40:52 +0000 (14:40 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 29 May 2020 13:18:17 +0000 (15:18 +0200)
Do not declare RuntimeException as thrown and do not wrap reported
RuntimeExceptions. Also make sure we use IllegalStateException as
the wrapper.

JIRA: MDSAL-556
Change-Id: Ifc47004c6d5cc2c974045c3f4d94154b506c8ebd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
(cherry picked from commit 4e78a1e85ca3bd04a204bb05ab3fa1695cbbf94b)

binding/mdsal-binding-test-utils/src/main/java/org/opendaylight/mdsal/binding/testutils/DataBrokerTestModule.java

index 234a4cdcb3fec739325df2ef04b42afbc3bf629d..1560795283d070887bdfb90314185a42190388cb 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.mdsal.binding.testutils;
 
 import com.google.common.annotations.Beta;
+import com.google.common.base.Throwables;
 import org.opendaylight.mdsal.binding.api.DataBroker;
 import org.opendaylight.mdsal.binding.dom.adapter.BindingToNormalizedNodeCodec;
 import org.opendaylight.mdsal.binding.dom.adapter.test.AbstractConcurrentDataBrokerTest;
@@ -31,8 +32,8 @@ public class DataBrokerTestModule {
     }
 
     // Suppress IllegalCatch because of AbstractDataBrokerTest (change later)
-    @SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:IllegalThrows" })
-    public DataBroker getDataBroker() throws RuntimeException {
+    @SuppressWarnings("checkstyle:IllegalCatch")
+    public DataBroker getDataBroker() {
         try {
             // This is a little bit "upside down" - in the future,
             // we should probably put what is in AbstractDataBrokerTest
@@ -43,7 +44,8 @@ public class DataBrokerTestModule {
             dataBrokerTest.setup();
             return dataBrokerTest.getDataBroker();
         } catch (Exception e) {
-            throw new RuntimeException(e);
+            Throwables.throwIfUnchecked(e);
+            throw new IllegalStateException(e);
         }
     }