Bug 8424: Don't output data tree and tree candidates wih debug
[controller.git] / opendaylight / md-sal / cds-access-api / src / main / java / org / opendaylight / controller / cluster / access / commands / ConnectClientSuccess.java
index c2302598e339b03101767603f94d81059759d060..90eff1b227922f9892186df9a6acae40c2d2dc91 100644 (file)
@@ -13,6 +13,7 @@ import com.google.common.annotations.Beta;
 import com.google.common.base.MoreObjects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import java.util.List;
 import java.util.Optional;
 import javax.annotation.Nonnull;
@@ -32,22 +33,30 @@ import org.opendaylight.yangtools.yang.data.api.schema.tree.DataTree;
 public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier, ConnectClientSuccess> {
     private static final long serialVersionUID = 1L;
 
+    @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "This field is not Serializable but this class "
+            + "implements writeReplace to delegate serialization to a Proxy class and thus instances of this class "
+            + "aren't serialized. FindBugs does not recognize this.")
     private final List<ActorSelection> alternates;
+
+    @SuppressFBWarnings(value = "SE_BAD_FIELD", justification = "See justification above.")
     private final DataTree dataTree;
     private final ActorRef backend;
+    private final int maxMessages;
 
-    ConnectClientSuccess(final ClientIdentifier target, final ActorRef backend, final List<ActorSelection> alternates,
-        final Optional<DataTree> dataTree) {
-        super(target);
+    ConnectClientSuccess(final ClientIdentifier target, final long sequence, final ActorRef backend,
+        final List<ActorSelection> alternates, final Optional<DataTree> dataTree, final int maxMessages) {
+        super(target, sequence);
         this.backend = Preconditions.checkNotNull(backend);
         this.alternates = ImmutableList.copyOf(alternates);
         this.dataTree = dataTree.orElse(null);
+        Preconditions.checkArgument(maxMessages > 0, "Maximum messages has to be positive, not %s", maxMessages);
+        this.maxMessages = maxMessages;
     }
 
-    public ConnectClientSuccess(final @Nonnull ClientIdentifier target, final @Nonnull ActorRef backend,
-            final @Nonnull List<ActorSelection> alternates,
-            final @Nonnull DataTree dataTree) {
-        this(target, backend, alternates, Optional.of(dataTree));
+    public ConnectClientSuccess(@Nonnull final ClientIdentifier target, final long sequence,
+            @Nonnull final ActorRef backend, @Nonnull final List<ActorSelection> alternates,
+            @Nonnull final DataTree dataTree, final int maxMessages) {
+        this(target, sequence, backend, alternates, Optional.of(dataTree), maxMessages);
     }
 
     /**
@@ -55,11 +64,13 @@ public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier,
      *
      * @return a list of known backend alternates
      */
-    public @Nonnull List<ActorSelection> getAlternates() {
+    @Nonnull
+    public List<ActorSelection> getAlternates() {
         return alternates;
     }
 
-    public @Nonnull ActorRef getBackend() {
+    @Nonnull
+    public ActorRef getBackend() {
         return backend;
     }
 
@@ -67,6 +78,10 @@ public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier,
         return Optional.ofNullable(dataTree);
     }
 
+    public int getMaxMessages() {
+        return maxMessages;
+    }
+
     @Override
     protected ConnectClientSuccessProxyV1 externalizableProxy(final ABIVersion version) {
         return new ConnectClientSuccessProxyV1(this);
@@ -79,6 +94,7 @@ public final class ConnectClientSuccess extends RequestSuccess<ClientIdentifier,
 
     @Override
     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
-        return super.addToStringAttributes(toStringHelper).add("alternates", alternates).add("dataTree", dataTree);
+        return super.addToStringAttributes(toStringHelper).add("alternates", alternates)
+                .add("dataTree present", getDataTree().isPresent()).add("maxMessages", maxMessages);
     }
 }