From: Robert Varga Date: Sun, 18 Oct 2020 20:21:01 +0000 (+0200) Subject: Properly cache caseType class X-Git-Tag: v7.0.1~3 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=0c711d61963257cb187ba66ff3ab3dcfa759cdee;p=mdsal.git Properly cache caseType class 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 --- diff --git a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java index fef5fea5d5..e25ac36dad 100644 --- a/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java +++ b/binding/mdsal-binding-dom-codec/src/main/java/org/opendaylight/mdsal/binding/dom/codec/impl/SchemaRootCodecContext.java @@ -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 extends DataContainerCo final List builder) { final Optional> 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 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); }