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/12/03 20:58:49 UTC

[GitHub] [geode-native] pivotal-jbarrett commented on a change in pull request #704: GEODE-8754: Fix uninitialized variable in DataInput::ReadInternalObject

pivotal-jbarrett commented on a change in pull request #704:
URL: https://github.com/apache/geode-native/pull/704#discussion_r535606476



##########
File path: tests/javaobject/cli/TestClassC.java
##########
@@ -0,0 +1,94 @@
+/*
+ * 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 javaobject.cli;
+
+import java.util.*;
+import java.io.*;
+import org.apache.geode.*;
+import org.apache.geode.cache.Declarable;
+
+public class TestClassC implements Declarable, Serializable, DataSerializable {
+  private String Color;
+  private String Make;
+  private int Year;
+
+  static {
+     Instantiator.register(new Instantiator(javaobject.cli.TestClassC.class, (byte) 102) {
+     public DataSerializable newInstance() {
+        return new TestClassC();
+     }
+   });
+  }
+
+  /* public no-arg constructor required for DataSerializable */  
+  public TestClassC() {}
+
+  public TestClassC(String color, String make, int year){
+    Color = color;
+    Make = make;
+    Year = year;
+  }
+  
+  public String toString(){
+    return "TestClassC [Color="+Color+" Make="+Make+ " Year="+Year +"]";
+  }
+  
+  public void fromData(DataInput in) throws IOException, ClassNotFoundException {
+    this.Color = in.readUTF();
+    this.Make = in.readUTF();
+    this.Year = in.readInt();
+  }
+  
+  public void toData(DataOutput out) throws IOException {
+    out.writeUTF(this.Color);
+    out.writeUTF(this.Make);
+    out.writeInt(this.Year);
+
+  } 
+  
+  public static boolean compareForEquals(Object first, Object second) {
+    if (first == null && second == null) return true;
+    if (first != null && first.equals(second)) return true;
+    return false;
+  }
+  
+  public boolean equals(Object other) {
+    if (other==null) return false;
+    if (!(other instanceof TestClassC)) return false;
+    
+    TestClassC testclass = (TestClassC) other;
+    
+    if (this.Color != testclass.Color) return false;
+    if (this.Make != testclass.Make) return false;
+    if (this.Year != testclass.Year) return false;
+
+    return true;    
+  }
+  
+  public int hashCode() {
+    String color = new String(Color);
+    String make = new String(Make);
+    Integer year = new Integer(Year);
+
+    int hashcode =
+	  color.hashCode() ^
+	  make.hashCode() ^
+	  year.hashCode();
+    
+    return hashcode;
+  }
+}

Review comment:
       Missing a few terminating line feeds if you haven't noticed the (-) indicator here on your new files.




----------------------------------------------------------------
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