Remove deprecated NormalizedNodeInputStreamReader ctor 15/58015/3
authorTom Pantelis <tompantelis@gmail.com>
Tue, 30 May 2017 13:16:28 +0000 (09:16 -0400)
committerRobert Varga <nite@hq.sk>
Tue, 6 Jun 2017 15:03:22 +0000 (15:03 +0000)
The intent is for NormalizedNodeInputStreamReader to be package-scoped
and to create instances via NormalizedNodeInputOutput#newDataInput.
Thus the deprecated public constructor was removed and the remaining
users were converted to use NormalizedNodeInputOutput#newDataInput.
However newDataInput has the side-effect of validating the input stream
first which failed for a couple users who need to lazily do the
validation so I added a newDataInputWithoutValidation method.

Change-Id: Ieb97ab77d05d7a4401dd0526cd4df3a5eafc9eda
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputOutput.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/NormalizedNodeInputStreamReader.java
opendaylight/md-sal/sal-clustering-commons/src/main/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SerializationUtils.java
opendaylight/md-sal/sal-clustering-commons/src/test/java/org/opendaylight/controller/cluster/datastore/node/utils/stream/SampleNormalizedNodeSerializable.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/messages/DataChanged.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/modification/MutableCompositeModification.java
opendaylight/md-sal/sal-distributed-datastore/src/main/java/org/opendaylight/controller/cluster/datastore/persisted/DataTreeCandidateInputOutput.java

index 5b93b27..486891d 100644 (file)
@@ -19,6 +19,14 @@ public final class NormalizedNodeInputOutput {
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * Creates a new {@link NormalizedNodeDataInput} instance that reads from the given input. This method first reads
+     * and validates that the input contains a valid NormalizedNode stream.
+     *
+     * @param input the DataInput to read from
+     * @return a new {@link NormalizedNodeDataInput} instance
+     * @throws IOException if an error occurs reading from the input
+     */
     public static NormalizedNodeDataInput newDataInput(@Nonnull final DataInput input) throws IOException {
         final byte marker = input.readByte();
         if (marker != TokenTypes.SIGNATURE_MARKER) {
@@ -34,7 +42,24 @@ public final class NormalizedNodeInputOutput {
         }
     }
 
-    public static NormalizedNodeDataOutput newDataOutput(@Nonnull final DataOutput output) throws IOException {
+    /**
+     * Creates a new {@link NormalizedNodeDataInput} instance that reads from the given input. This method does not
+     * perform any initial validation of the input stream.
+     *
+     * @param input the DataInput to read from
+     * @return a new {@link NormalizedNodeDataInput} instance
+     */
+    public static NormalizedNodeDataInput newDataInputWithoutValidation(@Nonnull final DataInput input) {
+        return new NormalizedNodeInputStreamReader(input, false);
+    }
+
+    /**
+     * Creates a new {@link NormalizedNodeDataOutput} instance that writes to the given output.
+     *
+     * @param output the DataOutput to write to
+     * @return a new {@link NormalizedNodeDataOutput} instance
+     */
+    public static NormalizedNodeDataOutput newDataOutput(@Nonnull final DataOutput output) {
         return new NormalizedNodeOutputStreamWriter(output);
     }
 }
index 4cc63d0..989884c 100644 (file)
@@ -74,16 +74,6 @@ public class NormalizedNodeInputStreamReader implements NormalizedNodeDataInput
 
     private boolean readSignatureMarker = true;
 
-    /**
-     * Constructs an instance.
-     *
-     * @deprecated Use {@link NormalizedNodeInputOutput#newDataInput(DataInput)} instead.
-     */
-    @Deprecated
-    public NormalizedNodeInputStreamReader(final DataInput input) {
-        this(input, false);
-    }
-
     NormalizedNodeInputStreamReader(final DataInput input, final boolean versionChecked) {
         this.input = Preconditions.checkNotNull(input);
         readSignatureMarker = !versionChecked;
index fc04972..e4fd936 100644 (file)
@@ -31,7 +31,7 @@ public final class SerializationUtils {
         void apply(T instance, YangInstanceIdentifier path, NormalizedNode<?, ?> node);
     }
 
-    private static NormalizedNodeDataOutput streamWriter(DataOutput out) throws IOException {
+    private static NormalizedNodeDataOutput streamWriter(DataOutput out) {
         NormalizedNodeDataOutput streamWriter = REUSABLE_WRITER_TL.get();
         if (streamWriter == null) {
             streamWriter = NormalizedNodeInputOutput.newDataOutput(out);
index 365dab7..ea89e20 100644 (file)
@@ -32,7 +32,7 @@ public class SampleNormalizedNodeSerializable implements Serializable {
 
     private void readObject(final ObjectInputStream stream)
             throws IOException, ClassNotFoundException, URISyntaxException {
-        NormalizedNodeDataInput reader = new NormalizedNodeInputStreamReader(stream);
+        NormalizedNodeDataInput reader = NormalizedNodeInputOutput.newDataInput(stream);
         this.input = reader.readNormalizedNode();
     }
 
index c48adf2..3cc6d04 100644 (file)
@@ -18,7 +18,6 @@ import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputStreamReader;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.dom.store.impl.DOMImmutableDataChangeEvent;
@@ -46,7 +45,7 @@ public class DataChanged implements Externalizable {
     public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
         in.readShort(); // Read the version
 
-        NormalizedNodeDataInput streamReader = new NormalizedNodeInputStreamReader(in);
+        NormalizedNodeDataInput streamReader = NormalizedNodeInputOutput.newDataInputWithoutValidation(in);
 
         // Note: the scope passed to builder is not actually used.
         Builder builder = DOMImmutableDataChangeEvent.builder(DataChangeScope.SUBTREE);
index f2a8c00..5a2c805 100644 (file)
@@ -18,7 +18,6 @@ import java.util.List;
 import org.opendaylight.controller.cluster.datastore.DataStoreVersions;
 import org.opendaylight.controller.cluster.datastore.messages.VersionedExternalizableMessage;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputStreamReader;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.SerializationUtils;
 import org.opendaylight.controller.sal.core.spi.data.DOMStoreWriteTransaction;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeModification;
@@ -91,7 +90,7 @@ public class MutableCompositeModification extends VersionedExternalizableMessage
         int size = in.readInt();
 
         if (size > 1) {
-            SerializationUtils.REUSABLE_READER_TL.set(new NormalizedNodeInputStreamReader(in));
+            SerializationUtils.REUSABLE_READER_TL.set(NormalizedNodeInputOutput.newDataInputWithoutValidation(in));
         }
 
         try {
index c2a8733..fb9b07a 100644 (file)
@@ -17,7 +17,6 @@ import java.util.Collections;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataInput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeDataOutput;
 import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputOutput;
-import org.opendaylight.controller.cluster.datastore.node.utils.stream.NormalizedNodeInputStreamReader;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
 import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTreeCandidate;
@@ -98,7 +97,7 @@ public final class DataTreeCandidateInputOutput {
     }
 
     public static DataTreeCandidate readDataTreeCandidate(final DataInput in) throws IOException {
-        final NormalizedNodeDataInput reader = new NormalizedNodeInputStreamReader(in);
+        final NormalizedNodeDataInput reader = NormalizedNodeInputOutput.newDataInput(in);
         final YangInstanceIdentifier rootPath = reader.readYangInstanceIdentifier();
         final byte type = reader.readByte();
 

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.