BUG-7464: Do not check twice for prev to be null 77/49877/6
authorRobert Varga <rovarga@cisco.com>
Fri, 30 Dec 2016 15:12:52 +0000 (16:12 +0100)
committerRobert Varga <rovarga@cisco.com>
Mon, 9 Jan 2017 14:17:12 +0000 (15:17 +0100)
Since we have performed a null check first and then downgraded
the unneeded instanceof check, we are left with a pure else-branch,
which proves the RuntimeException is not thrown.

Change-Id: I9dd8ba2d20738854a2790891dd6cfe099df91146
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
third-party/triemap/src/main/java/org/opendaylight/yangtools/triemap/INode.java

index 3aca658cd50337deb9a375fab457508d502640f6..2a59f01afea4e73a3eda6f00738851f10ace1975 100644 (file)
@@ -49,7 +49,7 @@ final class INode<K, V> extends INodeBase<K, V> {
                 return null;
             } else {
                 // complete the GCAS
-                MainNode<K, V> prev = /* READ */ m.READ_PREV();
+                final MainNode<K, V> prev = /* READ */ m.READ_PREV();
                 INode<K, V> ctr = ct.readRoot(true);
 
                 if (prev == null) {
@@ -67,7 +67,7 @@ final class INode<K, V> extends INodeBase<K, V> {
                         m = /* READ */ READ();
                         continue;
                     }
-                } else if (prev != null) {
+                } else {
                     // Assume that you've read the root from the generation
                     // G.
                     // Assume that the snapshot algorithm is correct.
@@ -96,7 +96,6 @@ final class INode<K, V> extends INodeBase<K, V> {
                     }
                 }
             }
-            throw new RuntimeException ("Should not happen");
         }
     }