Properly cache caseType class 52/93152/2
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 18 Oct 2020 20:21:01 +0000 (22:21 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 19 Oct 2020 10:15:00 +0000 (10:15 +0000)
We lost this bit when we were switching annotations. Since we
require Java 11, we should no longer be exposed to the JDK issue.

Change-Id: I769686186f1b03a2bd7e00bbc9474d91278c8d91
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java

index fef5fea5d532bfc588ece0753c02737005047e38..e25ac36dadf57bd2ac484c7331b538b44454c808 100644 (file)
@@ -21,6 +21,7 @@ import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Type;
 import java.util.List;
 import java.util.Optional;
+import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.mdsal.binding.spec.naming.BindingMapping;
 import org.opendaylight.mdsal.binding.spec.reflect.BindingReflections;
 import org.opendaylight.yangtools.util.ClassLoaderUtils;
@@ -309,11 +310,10 @@ final class SchemaRootCodecContext<D extends DataObject> extends DataContainerCo
             final List<PathArgument> builder) {
         final Optional<? extends Class<? extends DataObject>> caseType = arg.getCaseType();
         if (caseType.isPresent()) {
-            // XXX: we use two caseType.get()s because of https://bugs.openjdk.java.net/browse/JDK-8144185,
-            //      which makes JaCoCo blow up if we try using @NonNull on the local variable.
-            final ChoiceNodeCodecContext<?> choice = choicesByClass.getUnchecked(caseType.get());
+            final @NonNull Class<? extends DataObject> type = caseType.orElseThrow();
+            final ChoiceNodeCodecContext<?> choice = choicesByClass.getUnchecked(type);
             choice.addYangPathArgument(arg, builder);
-            final DataContainerCodecContext<?, ?> caze = choice.streamChild(caseType.get());
+            final DataContainerCodecContext<?, ?> caze = choice.streamChild(type);
             caze.addYangPathArgument(arg, builder);
             return caze.bindingPathArgumentChild(arg, builder);
         }