From f2b206bdd68f50922fb9a0d829f4b9429502dbee Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Wed, 11 Jan 2023 00:29:26 +0100 Subject: [PATCH] Mark a potential CCE We have blind cast here, mark it for fixing. Change-Id: I77812192fb772fd8f9224db75bd5adaf0db97f77 Signed-off-by: Robert Varga --- .../rests/services/impl/CreateStreamUtil.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java index 274d9660dd..13972dcca9 100644 --- a/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java +++ b/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/services/impl/CreateStreamUtil.java @@ -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}. * -- 2.36.6