BUG-9160: fix ReadDataTransactionUtil creating two adapters 22/63122/6
authorwusandi <wusandi@163.com>
Thu, 14 Sep 2017 06:58:56 +0000 (14:58 +0800)
committerwusandi <wusandi@163.com>
Thu, 7 Dec 2017 06:56:19 +0000 (14:56 +0800)
It should not directly add all of NotificationListenerAdapter objects
for XML stream to the list of NotificationListenerAdapter for JSON stream.
And to fix it, just to concat them together instead of putting one to
another.

Change-Id: I2c8eedc04281f10ea6742db854309d8182b1966b
Signed-off-by: wusandi <wusandi@163.com>
restconf/restconf-nb-rfc8040/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/ReadDataTransactionUtil.java

index 5272482c693e0e29ad2ccfe78199b8a33ec85436..2aa4f0603b815b74c8e59190cffa11398fb466fe 100644 (file)
@@ -11,6 +11,7 @@ import static org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsCo
 import static org.opendaylight.restconf.nb.rfc8040.rests.utils.RestconfStreamsConstants.STREAM_PATH_PART;
 
 import com.google.common.base.Optional;
+import com.google.common.collect.Iterables;
 import com.google.common.primitives.Ints;
 import com.google.common.util.concurrent.CheckedFuture;
 import java.net.URI;
@@ -280,9 +281,7 @@ public final class ReadDataTransactionUtil {
                 final List<NotificationListenerAdapter> notifiStreamJSON =
                         CreateStreamUtil.createYangNotifiStream(notificationDefinition, schemaContextRef,
                                 NotificationOutputType.JSON.getName());
-                notifiStreamJSON.addAll(notifiStreamXML);
-
-                for (final NotificationListenerAdapter listener : notifiStreamJSON) {
+                for (final NotificationListenerAdapter listener : Iterables.concat(notifiStreamXML, notifiStreamJSON)) {
                     final URI uri = SubscribeToStreamUtil.prepareUriByStreamName(uriInfo, listener.getStreamName());
                     final NormalizedNode mapToStreams =
                             RestconfMappingNodeUtil.mapYangNotificationStreamByIetfRestconfMonitoring(