You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/11/25 11:09:05 UTC

[GitHub] [geode] mkevo commented on a change in pull request #5730: GEODE-8687: Fix for handling of PdxSerializationException on client

mkevo commented on a change in pull request #5730:
URL: https://github.com/apache/geode/pull/5730#discussion_r530290653



##########
File path: geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientCQAutoSerializer.java
##########
@@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.tier.sockets;
+
+import static org.apache.geode.cache.Region.SEPARATOR;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Objects;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientRegionFactory;
+import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.cache.client.internal.PoolImpl;
+import org.apache.geode.cache.query.CqAttributesFactory;
+import org.apache.geode.cache.query.CqQuery;
+import org.apache.geode.cache.query.QueryService;
+import org.apache.geode.internal.cache.CacheServerImpl;
+import org.apache.geode.pdx.ReflectionBasedAutoSerializer;
+import org.apache.geode.pdx.internal.AutoSerializableManager;
+import org.apache.geode.test.dunit.Invoke;
+import org.apache.geode.test.dunit.rules.ClientVM;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+
+@Category({ClientSubscriptionTest.class, SerializationTest.class})
+public class DurableClientCQAutoSerializer implements Serializable {
+  private static final String REPLICATE_REGION_NAME = "ReplicateRegion";
+  private static final String PARTITION_REGION_NAME = "PartitionRegion";
+
+  private MemberVM server;
+  private MemberVM server2;
+  private MemberVM locator;
+  private ClientVM client;
+  private ClientVM client2;
+
+  private static TestAutoSerializerCqListener cqListener = null;
+
+  private static final String TEST_OBJECT1_CLASS_PATH =
+      "org.apache.geode.internal.cache.tier.sockets.TestAutoSerializerObject1";
+  private static final String TEST_OBJECT2_CLASS_PATH =
+      "org.apache.geode.internal.cache.tier.sockets.TestAutoSerializerObject2";
+  private static final String TEST_FAULTY_CLASS_PATH =
+      "org.apache.geode.internal.cache.tier.sockets.TestAutoSerializerObject2Faulty";
+  private static final String DURABLE_CLIENT_ID = "durableClient";
+
+  // Traffic data
+  static final Map<String, TestAutoSerializerObject1> LIST_TEST_OBJECT1 = ImmutableMap.of(
+      "key1", new TestAutoSerializerObject1("aa", "bb", 300),
+      "key2", new TestAutoSerializerObject1("aa", "bb", 600),
+      "key3", new TestAutoSerializerObject1("aaa", "bbb", 500));
+
+  static final Map<String, TestAutoSerializerObject2> LIST_TEST_OBJECT2 = ImmutableMap.of(
+      "key1", new TestAutoSerializerObject2("cc", "ddd", 300),
+      "key2", new TestAutoSerializerObject2("cc", "dddd", 400));
+
+  @Rule
+  public GfshCommandRule gfsh = new GfshCommandRule();
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule(5);
+
+  @Before
+  public void setUp() throws Exception {
+    Invoke.invokeInEveryVM(
+        () -> System.setProperty(AutoSerializableManager.NO_HARDCODED_EXCLUDES_PARAM, "true"));
+
+    locator =
+        cluster.startLocatorVM(0);
+    int locatorPort = locator.getPort();
+    server = cluster.startServerVM(1,
+        s -> s.withConnectionToLocator(locatorPort));
+
+    server2 = cluster.startServerVM(2,
+        s -> s.withConnectionToLocator(locatorPort));
+
+    gfsh.connectAndVerify(locator);
+    gfsh.executeAndAssertThat(
+        "configure pdx --auto-serializable-classes='" + TEST_OBJECT1_CLASS_PATH + ", "
+            + TEST_OBJECT2_CLASS_PATH + "'")
+        .statusIsSuccess();
+    gfsh.executeAndAssertThat("create region --name=" + REPLICATE_REGION_NAME + " --type=REPLICATE")
+        .statusIsSuccess();
+    gfsh.executeAndAssertThat("create region --name=" + PARTITION_REGION_NAME + " --type=PARTITION")
+        .statusIsSuccess();
+
+    locator.invoke(() -> {
+      ClusterStartupRule.memberStarter
+          .waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + REPLICATE_REGION_NAME, 2);
+      ClusterStartupRule.memberStarter
+          .waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + PARTITION_REGION_NAME, 2);
+    });
+  }
+
+  @Test
+  public void correctClassPathsAutoSerializer()

Review comment:
       Please change the test name. Something like _testcorrectClassPathsAutoSerializer_

##########
File path: geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientCQAutoSerializer.java
##########
@@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.tier.sockets;
+
+import static org.apache.geode.cache.Region.SEPARATOR;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Objects;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientRegionFactory;
+import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.cache.client.internal.PoolImpl;
+import org.apache.geode.cache.query.CqAttributesFactory;
+import org.apache.geode.cache.query.CqQuery;
+import org.apache.geode.cache.query.QueryService;
+import org.apache.geode.internal.cache.CacheServerImpl;
+import org.apache.geode.pdx.ReflectionBasedAutoSerializer;
+import org.apache.geode.pdx.internal.AutoSerializableManager;
+import org.apache.geode.test.dunit.Invoke;
+import org.apache.geode.test.dunit.rules.ClientVM;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+
+@Category({ClientSubscriptionTest.class, SerializationTest.class})
+public class DurableClientCQAutoSerializer implements Serializable {

Review comment:
       Please rename this file to be clear that it is the test. Something like _DurableClientCQAutoSerializerDUnitTest_

##########
File path: geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/DurableClientCQAutoSerializer.java
##########
@@ -0,0 +1,289 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.tier.sockets;
+
+import static org.apache.geode.cache.Region.SEPARATOR;
+import static org.apache.geode.test.awaitility.GeodeAwaitility.await;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Objects;
+
+import com.google.common.collect.ImmutableMap;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+
+import org.apache.geode.cache.Region;
+import org.apache.geode.cache.client.ClientCache;
+import org.apache.geode.cache.client.ClientRegionFactory;
+import org.apache.geode.cache.client.ClientRegionShortcut;
+import org.apache.geode.cache.client.internal.PoolImpl;
+import org.apache.geode.cache.query.CqAttributesFactory;
+import org.apache.geode.cache.query.CqQuery;
+import org.apache.geode.cache.query.QueryService;
+import org.apache.geode.internal.cache.CacheServerImpl;
+import org.apache.geode.pdx.ReflectionBasedAutoSerializer;
+import org.apache.geode.pdx.internal.AutoSerializableManager;
+import org.apache.geode.test.dunit.Invoke;
+import org.apache.geode.test.dunit.rules.ClientVM;
+import org.apache.geode.test.dunit.rules.ClusterStartupRule;
+import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.categories.ClientSubscriptionTest;
+import org.apache.geode.test.junit.categories.SerializationTest;
+import org.apache.geode.test.junit.rules.GfshCommandRule;
+
+@Category({ClientSubscriptionTest.class, SerializationTest.class})
+public class DurableClientCQAutoSerializer implements Serializable {
+  private static final String REPLICATE_REGION_NAME = "ReplicateRegion";
+  private static final String PARTITION_REGION_NAME = "PartitionRegion";
+
+  private MemberVM server;
+  private MemberVM server2;
+  private MemberVM locator;
+  private ClientVM client;
+  private ClientVM client2;
+
+  private static TestAutoSerializerCqListener cqListener = null;
+
+  private static final String TEST_OBJECT1_CLASS_PATH =
+      "org.apache.geode.internal.cache.tier.sockets.TestAutoSerializerObject1";
+  private static final String TEST_OBJECT2_CLASS_PATH =
+      "org.apache.geode.internal.cache.tier.sockets.TestAutoSerializerObject2";
+  private static final String TEST_FAULTY_CLASS_PATH =
+      "org.apache.geode.internal.cache.tier.sockets.TestAutoSerializerObject2Faulty";
+  private static final String DURABLE_CLIENT_ID = "durableClient";
+
+  // Traffic data
+  static final Map<String, TestAutoSerializerObject1> LIST_TEST_OBJECT1 = ImmutableMap.of(
+      "key1", new TestAutoSerializerObject1("aa", "bb", 300),
+      "key2", new TestAutoSerializerObject1("aa", "bb", 600),
+      "key3", new TestAutoSerializerObject1("aaa", "bbb", 500));
+
+  static final Map<String, TestAutoSerializerObject2> LIST_TEST_OBJECT2 = ImmutableMap.of(
+      "key1", new TestAutoSerializerObject2("cc", "ddd", 300),
+      "key2", new TestAutoSerializerObject2("cc", "dddd", 400));
+
+  @Rule
+  public GfshCommandRule gfsh = new GfshCommandRule();
+
+  @Rule
+  public ClusterStartupRule cluster = new ClusterStartupRule(5);
+
+  @Before
+  public void setUp() throws Exception {
+    Invoke.invokeInEveryVM(
+        () -> System.setProperty(AutoSerializableManager.NO_HARDCODED_EXCLUDES_PARAM, "true"));
+
+    locator =
+        cluster.startLocatorVM(0);
+    int locatorPort = locator.getPort();
+    server = cluster.startServerVM(1,
+        s -> s.withConnectionToLocator(locatorPort));
+
+    server2 = cluster.startServerVM(2,
+        s -> s.withConnectionToLocator(locatorPort));
+
+    gfsh.connectAndVerify(locator);
+    gfsh.executeAndAssertThat(
+        "configure pdx --auto-serializable-classes='" + TEST_OBJECT1_CLASS_PATH + ", "
+            + TEST_OBJECT2_CLASS_PATH + "'")
+        .statusIsSuccess();
+    gfsh.executeAndAssertThat("create region --name=" + REPLICATE_REGION_NAME + " --type=REPLICATE")
+        .statusIsSuccess();
+    gfsh.executeAndAssertThat("create region --name=" + PARTITION_REGION_NAME + " --type=PARTITION")
+        .statusIsSuccess();
+
+    locator.invoke(() -> {
+      ClusterStartupRule.memberStarter
+          .waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + REPLICATE_REGION_NAME, 2);
+      ClusterStartupRule.memberStarter
+          .waitUntilRegionIsReadyOnExactlyThisManyServers(SEPARATOR + PARTITION_REGION_NAME, 2);
+    });
+  }
+
+  @Test
+  public void correctClassPathsAutoSerializer()
+      throws Exception {
+
+    String query1 = "SELECT * FROM " + SEPARATOR + REPLICATE_REGION_NAME;
+    String query2 = "SELECT * FROM " + SEPARATOR + PARTITION_REGION_NAME;
+
+    startDurableClient(TEST_OBJECT1_CLASS_PATH, TEST_OBJECT2_CLASS_PATH);
+    createDurableCQs(query1, query2);
+    verifyThatOnlyOneServerHostDurableSubscription();
+
+    // Start another client and provision data with traffic that should trigger CQs
+    startDataProvisionClient(TEST_OBJECT1_CLASS_PATH, TEST_OBJECT2_CLASS_PATH);
+    provisionRegionsWithData();
+
+    // Check that all events are received and successfully deserialized in cq listener
+    checkCqEvents(LIST_TEST_OBJECT1.size(), LIST_TEST_OBJECT2.size());
+    verifyThatOnlyOneServerHostDurableSubscription();
+  }
+
+  @Test
+  public void faultyClassPathAutoSerializer()

Review comment:
       The same as above. Something like _testfaultyClassPathAutoSerializer_

##########
File path: geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/TestAutoSerializerObject1.java
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.tier.sockets;
+
+import java.util.Objects;
+
+import org.apache.geode.internal.PdxSerializerObject;
+
+/**
+ * <strong>Explicitly</strong> not serializable by java.io.Serializable,
+ * org.apache.geode.DataSerializable, or org.apache.geode.pdx.PdxSerializable.
+ */
+public class TestAutoSerializerObject1 implements PdxSerializerObject {
+  protected String data1;
+  protected String data2;
+  protected int numData3;
+
+  public TestAutoSerializerObject1() {
+    this("", "", 0);
+  }
+
+  protected TestAutoSerializerObject1(String data1, String data2, int numData3) {

Review comment:
       Please change this _numData3_ to _numData_, also change get methods.

##########
File path: geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/TestAutoSerializerObject1.java
##########
@@ -0,0 +1,113 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.tier.sockets;
+
+import java.util.Objects;
+
+import org.apache.geode.internal.PdxSerializerObject;
+
+/**
+ * <strong>Explicitly</strong> not serializable by java.io.Serializable,
+ * org.apache.geode.DataSerializable, or org.apache.geode.pdx.PdxSerializable.
+ */
+public class TestAutoSerializerObject1 implements PdxSerializerObject {
+  protected String data1;
+  protected String data2;
+  protected int numData3;
+
+  public TestAutoSerializerObject1() {
+    this("", "", 0);
+  }
+
+  protected TestAutoSerializerObject1(String data1, String data2, int numData3) {
+    this.data1 = data1;
+    this.data2 = data2;
+    this.numData3 = numData3;
+  }
+
+  public String getData1() {
+    return data1;
+  }
+
+  public String getData2() {
+    return data2;
+  }
+
+  public void setData2(String data2) {
+    this.data2 = data2;
+  }
+
+  public int getNumData3() {
+    return numData3;
+  }
+
+  public void setNumData3(int numData3) {
+    this.numData3 = numData3;
+  }
+
+  public String toString() {
+    StringBuilder builder = new StringBuilder();
+    if (data1 != null && !data1.isEmpty()) {
+      builder.append(data1);
+      builder.append(" (");
+
+      if (data2 != null && !data2.isEmpty()) {
+        if (0 < builder.length() && '(' != builder.charAt(builder.length() - 1)) {
+          builder.append(", ");
+        }
+        builder.append("data2: ");
+        builder.append(data2);
+      }
+
+      if (0 < numData3) {
+        if (0 < builder.length() && '(' != builder.charAt(builder.length() - 1)) {
+          builder.append(", ");
+        }
+        builder.append("numData3: ");
+        builder.append(numData3);
+      }
+
+      builder.append(")");
+    }
+    return builder.toString();
+  }
+
+  @Override
+  public boolean equals(Object o) {
+
+    if (this == o)
+      return true;
+
+    if (o == null)
+      return false;
+
+    if (getClass() != o.getClass())

Review comment:
       Can you merge this if statement with one above as they returning the same value? 

##########
File path: geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/TestAutoSerializerObject2.java
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.tier.sockets;
+
+import java.util.Objects;
+
+import org.apache.geode.internal.PdxSerializerObject;
+
+/**
+ * <strong>Explicitly</strong> not serializable by java.io.Serializable,
+ * org.apache.geode.DataSerializable, or org.apache.geode.pdx.PdxSerializable.
+ */
+public class TestAutoSerializerObject2 implements PdxSerializerObject {
+  protected String data1;
+  protected String data2;
+  protected int numData3;
+
+  public TestAutoSerializerObject2() {
+    this("", "", 0);
+  }
+
+  protected TestAutoSerializerObject2(String data1, String data2, int numData3) {

Review comment:
       Please change this _numData3_ to _numData_, also change get methods.

##########
File path: geode-cq/src/distributedTest/java/org/apache/geode/internal/cache/tier/sockets/TestAutoSerializerObject2.java
##########
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License. You may obtain a
+ * copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.geode.internal.cache.tier.sockets;
+
+import java.util.Objects;
+
+import org.apache.geode.internal.PdxSerializerObject;
+
+/**
+ * <strong>Explicitly</strong> not serializable by java.io.Serializable,
+ * org.apache.geode.DataSerializable, or org.apache.geode.pdx.PdxSerializable.
+ */
+public class TestAutoSerializerObject2 implements PdxSerializerObject {
+  protected String data1;
+  protected String data2;
+  protected int numData3;
+
+  public TestAutoSerializerObject2() {
+    this("", "", 0);
+  }
+
+  protected TestAutoSerializerObject2(String data1, String data2, int numData3) {
+    this.data1 = data1;
+    this.data2 = data2;
+    this.numData3 = numData3;
+  }
+
+  public String getData1() {
+    return data1;
+  }
+
+  public String getData2() {
+    return data2;
+  }
+
+  public void setData2(String data2) {
+    this.data2 = data2;
+  }
+
+  public int getNumData3() {
+    return numData3;
+  }
+
+  public void setNumData3(int numData3) {
+    this.numData3 = numData3;
+  }
+
+  public String toString() {
+    StringBuilder builder = new StringBuilder();
+    if (data1 != null && !data1.isEmpty()) {
+      builder.append(data1);
+      builder.append(" (");
+
+      if (data2 != null && !data2.isEmpty()) {
+        if (0 < builder.length() && '(' != builder.charAt(builder.length() - 1)) {
+          builder.append(", ");
+        }
+        builder.append("data2: ");
+        builder.append(data2);
+      }
+
+      if (0 < numData3) {
+        if (0 < builder.length() && '(' != builder.charAt(builder.length() - 1)) {
+          builder.append(", ");
+        }
+        builder.append("numData3: ");
+        builder.append(numData3);
+      }
+
+      builder.append(")");
+    }
+    return builder.toString();
+  }
+
+  @Override
+  public boolean equals(Object o) {
+    if (this == o)
+      return true;
+
+    if (o == null)
+      return false;
+
+    if (getClass() != o.getClass())

Review comment:
       Can you merge this if statement with one above as they returning the same value? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org