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 5b93b274e0b757766e750efa8c5f8a129e9f6eed..486891dfd5e7328a7feb767852702fef43f5b627 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 4cc63d06b1ff4de0678c594663ceb4b5e2d5550c..989884cebdfa3d75d159686b92ba1a3cc5927e35 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 fc0497280cc59212f4feed17f1b7460c6a215af6..e4fd9363a6a28047304f547e0def404a3ca2bd30 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 365dab7d7b5a765a76fe154a53a27668abcddde5..ea89e2096a280bfb15925eb1c299254254133a61 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 c48adf2d80befc8ca62e25acb2fb6b4ad19ae04c..3cc6d041d8796d98d34770e15df19b3a8aef7d8e 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 f2a8c00d19035120b8bcac7b522d3d97465cd29e..5a2c8054be9b711154dd23ea7d8900624a7c6778 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 c2a873331d3d0e61f14c8c2b0faec18950f43507..fb9b07a5d00973d48169ab095e20cfeaf9931663 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();