Mark a potential CCE 76/103976/5
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 10 Jan 2023 23:29:26 +0000 (00:29 +0100)
committerRobert Varga <nite@hq.sk>
Mon, 30 Jan 2023 15:00:05 +0000 (15:00 +0000)
We have blind cast here, mark it for fixing.

Change-Id: I77812192fb772fd8f9224db75bd5adaf0db97f77
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java

index 274d9660ddac9e7c84fc285b241c3b7e6eda2b5b..13972dcca959b920f217b32a8c6794c84df6ff7d 100644 (file)
@@ -159,11 +159,16 @@ final class CreateStreamUtil {
             .map(DataContainerChild::body)
             .orElseThrow(() -> new RestconfDocumentedException("Mount point not available", ErrorType.APPLICATION,
                 ErrorTag.OPERATION_FAILED));
+
+        // FIXME: just beautiful: a ClassCastException if it is something different!
+        final String deviceName =
+            ((YangInstanceIdentifier.NodeIdentifierWithPredicates.Singleton)value.getLastPathArgument())
+            .values().getElement().toString();
+
         final DOMMountPoint mountPoint = mountPointService.getMountPoint(value)
             .orElseThrow(() -> new RestconfDocumentedException("Mount point not available", ErrorType.APPLICATION,
                 ErrorTag.OPERATION_FAILED));
 
-        final String deviceName = extractDeviceName(value);
         final NotificationOutputType outputType = prepareOutputType(data);
 
         // FIXME: what is the relationship to the unused refSchemaCtx?
@@ -194,11 +199,6 @@ final class CreateStreamUtil {
             .build());
     }
 
-    private static String extractDeviceName(final YangInstanceIdentifier iid) {
-        return ((YangInstanceIdentifier.NodeIdentifierWithPredicates.Singleton)iid.getLastPathArgument())
-            .values().getElement().toString();
-    }
-
     /**
      * Prepare {@link NotificationOutputType}.
      *