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/02 17:43:41 UTC

[GitHub] [geode-native] mmartell opened a new pull request #704: GEODE-8754: Fix uninitialized variable in DataInput::ReadInternalObject

mmartell opened a new pull request #704:
URL: https://github.com/apache/geode-native/pull/704


   This fixes an uninitialized variable in the clicache code (DataInput::ReadInternalObject). Also, added a new serialization test (CompositeClassWithClassAsKey) since there were no existing tests that executed this function.


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



[GitHub] [geode-native] mmartell merged pull request #704: GEODE-8754: Fix uninitialized variable in DataInput::ReadInternalObject

Posted by GitBox <gi...@apache.org>.
mmartell merged pull request #704:
URL: https://github.com/apache/geode-native/pull/704


   


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



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

Posted by GitBox <gi...@apache.org>.
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



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

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #704:
URL: https://github.com/apache/geode-native/pull/704#discussion_r535534729



##########
File path: clicache/src/DataInput.cpp
##########
@@ -657,7 +657,7 @@ namespace Apache
           //Log::Debug("DataInput::ReadInternalObject m_cursor " + m_cursor);
           bool findinternal = false;
           int8_t typeId = ReadByte();
-          System::Int64 compId;
+          System::Int64 compId = 0;

Review comment:
       Yes, it's a good idea to initialize things before you use them!




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



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

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #704:
URL: https://github.com/apache/geode-native/pull/704#discussion_r535384810



##########
File path: clicache/integration-test2/SerializationTests.cs
##########
@@ -510,5 +823,119 @@ public void PutGetCustomSerializableTypes()
                 cache.Close();
             }
         }
-    }
-}
+
+		[Fact]
+		public void CompositeClassWithClassAsKey()

Review comment:
       I agree we should have a separate ClassAsKey. It would only use ReadInternalObject if the class being used as the key had a member that was a container (i.e., list, vector, dictionary). I had it that way originally.
   
   




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



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

Posted by GitBox <gi...@apache.org>.
echobravopapa commented on a change in pull request #704:
URL: https://github.com/apache/geode-native/pull/704#discussion_r534420160



##########
File path: tests/javaobject/cli/TestClassC.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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();
+     }
+   });
+  }
+
+
+
+/*

Review comment:
       dead code, pls remove

##########
File path: clicache/src/DataInput.cpp
##########
@@ -657,7 +657,7 @@ namespace Apache
           //Log::Debug("DataInput::ReadInternalObject m_cursor " + m_cursor);
           bool findinternal = false;
           int8_t typeId = ReadByte();
-          System::Int64 compId;
+          System::Int64 compId = 0;

Review comment:
       RAII FTW?!?

##########
File path: clicache/integration-test2/SerializationTests.cs
##########
@@ -25,7 +26,335 @@
 
 namespace Apache.Geode.Client.IntegrationTests
 {
-    public class Order : IDataSerializable
+	public class TestClassA : IDataSerializable
+	{
+		public int Id { get; set; }
+		public string Name { get; set; }
+		public short NumSides { get; set; }
+
+		// A default constructor is required for deserialization
+		public TestClassA() { }
+
+		public TestClassA(int id, string name, short numSides)
+		{
+			Id = id;
+			Name = name;
+			NumSides = numSides;
+		}
+
+		public override string ToString()
+		{
+			return string.Format("TestClassA: [{0}, {1}, {2}]", Id, Name, NumSides);
+		}
+
+		public void ToData(DataOutput output)
+		{
+			output.WriteInt32(Id);
+			output.WriteUTF(Name);
+			output.WriteInt16(NumSides);
+		}
+
+		public void FromData(DataInput input)
+		{
+			Id = input.ReadInt32();
+			Name = input.ReadUTF();
+			NumSides = input.ReadInt16();
+		}
+
+		public ulong ObjectSize
+		{
+			get { return 0; }
+		}
+
+		public static ISerializable CreateDeserializable()
+		{
+			return new TestClassA();
+		}
+
+		public override bool Equals(object obj)
+		{
+			if (obj == null)
+				return false;
+			if (obj == this)
+				return true;
+
+			var other = obj as TestClassA;
+
+			if (Id == other.Id &&
+				Name == other.Name &&
+				NumSides == other.NumSides)
+				return true;
+			else
+				return false;
+		}
+
+		public override int GetHashCode()
+		{
+			return base.GetHashCode();
+		}
+	}
+
+	public class TestClassB : IDataSerializable
+	{
+		public int Width { get; set; }
+		public int Height { get; set; }
+		public string Name { get; set; }
+
+		// A default constructor is required for deserialization
+		public TestClassB() { }
+
+		public TestClassB(int width, int height, string name)
+		{
+			Width = width;
+			Height = height;
+			Name = name;
+		}
+
+		public override string ToString()
+		{
+			return string.Format("TestClassB: [{0}, {1}, {2}]", Width, Height, Name);
+		}
+
+		public void ToData(DataOutput output)
+		{
+			output.WriteInt32(Width);
+			output.WriteInt32(Height);
+			output.WriteUTF(Name);
+		}
+
+		public void FromData(DataInput input)
+		{
+			Width = input.ReadInt32();
+			Height = input.ReadInt32();
+			Name = input.ReadUTF();
+		}
+
+		public ulong ObjectSize
+		{
+			get { return 0; }
+		}
+
+		public static ISerializable CreateDeserializable()
+		{
+			return new TestClassB();
+		}
+
+		public override bool Equals(object obj)
+		{
+			if (obj == null)
+				return false;
+			if (obj == this)
+				return true;
+
+			var other = obj as TestClassB;
+
+			if (Width == other.Width &&
+				Name == other.Name &&
+				Height == other.Height)
+				return true;
+			else
+				return false;
+		}
+
+		public override int GetHashCode()
+		{
+			return base.GetHashCode();
+		}
+	}
+
+	public class TestClassC : IDataSerializable
+	{
+		public string Color { get; set; }
+		public string Make { get; set; }
+		public int Year { get; set; }
+
+		// A default constructor is required for deserialization
+		public TestClassC() { }
+
+		public TestClassC(string color, string make, int year)
+		{
+			Color = color;
+			Make = make;
+			Year = year;
+		}
+
+		public override string ToString()
+		{
+			return string.Format("TestClassC: [{0}, {1}, {2}]", Color, Make, Year);
+		}
+
+		public void ToData(DataOutput output)
+		{
+			output.WriteUTF(Color);
+			output.WriteUTF(Make);
+			output.WriteInt32(Year);
+		}
+
+		public void FromData(DataInput input)
+		{
+			Color = input.ReadUTF();
+			Make = input.ReadUTF();
+			Year = input.ReadInt32();
+		}
+
+		public ulong ObjectSize
+		{
+			get { return 0; }
+		}
+
+		public static ISerializable CreateDeserializable()
+		{
+			return new TestClassC();
+		}
+
+		public override bool Equals(object obj)
+		{
+			if (obj == null)
+				return false;
+			if (obj == this)
+				return true;
+
+			var other = obj as TestClassC;
+
+			if (Color == other.Color &&
+				Make == other.Make &&
+				Year == other.Year)
+				return true;
+			else
+				return false;
+		}
+
+		public override int GetHashCode()
+		{
+			return base.GetHashCode();
+		}
+	}
+
+	public class CompositeClass : IDataSerializable
+    {
+        private TestClassA testclassA;
+		private List<TestClassB> testclassBs;
+		private List<TestClassC> testclassCs;
+
+		public CompositeClass()
+		{
+			testclassA = new TestClassA();
+			testclassBs = new List<TestClassB>();
+			testclassCs = new List<TestClassC>();
+		}
+
+		public TestClassA A
+		{
+			get
+			{
+				return testclassA;
+			}
+			set
+			{
+				testclassA = value;
+			}
+		}
+
+		public List<TestClassB> Bs
+		{
+			get
+			{
+				return testclassBs;
+			}
+			set
+			{
+				testclassBs = value;
+			}
+		}
+
+		public List<TestClassC> Cs
+		{
+			get
+			{
+				return testclassCs;
+			}
+			set
+			{
+				testclassCs = value;
+			}
+		}
+
+		public void ToData(DataOutput output)
+		{
+			testclassA.ToData(output);
+			output.WriteObject(testclassBs);
+			output.WriteObject(testclassCs);
+		}
+
+		//private unsafe void fillstack(Int64[] val)
+		//{
+  //          return;
+		//}
+		public void FromData(DataInput input)
+		{
+			testclassA.FromData(input);
+
+			// Fill the stack with Order typeid: 66

Review comment:
       dead code?

##########
File path: clicache/integration-test2/SerializationTests.cs
##########
@@ -510,5 +823,119 @@ public void PutGetCustomSerializableTypes()
                 cache.Close();
             }
         }
-    }
-}
+
+		[Fact]
+		public void CompositeClassWithClassAsKey()

Review comment:
       Good addition.   Does a non-composite class used as a key exercise the same code paths?  if not, be great to add a test for that too...




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



[GitHub] [geode-native] lgtm-com[bot] commented on pull request #704: GEODE-8754: Fix uninitialized variable in DataInput::ReadInternalObject

Posted by GitBox <gi...@apache.org>.
lgtm-com[bot] commented on pull request #704:
URL: https://github.com/apache/geode-native/pull/704#issuecomment-737409611


   This pull request **introduces 4 alerts** when merging 2b2e3887f9b647963e14178e08f5f8a9d7d2a7fe into 5f14294535b0e90be01d5587f76f3ec9d0102e81 - [view on LGTM.com](https://lgtm.com/projects/g/apache/geode-native/rev/pr-a8386920d9a7f0618c9e17fa8ad68a55772b6160)
   
   **new alerts:**
   
   * 4 for Dereferenced variable may be null


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



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

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #704:
URL: https://github.com/apache/geode-native/pull/704#discussion_r535353084



##########
File path: clicache/integration-test2/SerializationTests.cs
##########
@@ -25,7 +26,335 @@
 
 namespace Apache.Geode.Client.IntegrationTests
 {
-    public class Order : IDataSerializable
+	public class TestClassA : IDataSerializable
+	{
+		public int Id { get; set; }
+		public string Name { get; set; }
+		public short NumSides { get; set; }
+
+		// A default constructor is required for deserialization
+		public TestClassA() { }
+
+		public TestClassA(int id, string name, short numSides)
+		{
+			Id = id;
+			Name = name;
+			NumSides = numSides;
+		}
+
+		public override string ToString()
+		{
+			return string.Format("TestClassA: [{0}, {1}, {2}]", Id, Name, NumSides);
+		}
+
+		public void ToData(DataOutput output)
+		{
+			output.WriteInt32(Id);
+			output.WriteUTF(Name);
+			output.WriteInt16(NumSides);
+		}
+
+		public void FromData(DataInput input)
+		{
+			Id = input.ReadInt32();
+			Name = input.ReadUTF();
+			NumSides = input.ReadInt16();
+		}
+
+		public ulong ObjectSize
+		{
+			get { return 0; }
+		}
+
+		public static ISerializable CreateDeserializable()
+		{
+			return new TestClassA();
+		}
+
+		public override bool Equals(object obj)
+		{
+			if (obj == null)
+				return false;
+			if (obj == this)
+				return true;
+
+			var other = obj as TestClassA;
+
+			if (Id == other.Id &&
+				Name == other.Name &&
+				NumSides == other.NumSides)
+				return true;
+			else
+				return false;
+		}
+
+		public override int GetHashCode()
+		{
+			return base.GetHashCode();
+		}
+	}
+
+	public class TestClassB : IDataSerializable
+	{
+		public int Width { get; set; }
+		public int Height { get; set; }
+		public string Name { get; set; }
+
+		// A default constructor is required for deserialization
+		public TestClassB() { }
+
+		public TestClassB(int width, int height, string name)
+		{
+			Width = width;
+			Height = height;
+			Name = name;
+		}
+
+		public override string ToString()
+		{
+			return string.Format("TestClassB: [{0}, {1}, {2}]", Width, Height, Name);
+		}
+
+		public void ToData(DataOutput output)
+		{
+			output.WriteInt32(Width);
+			output.WriteInt32(Height);
+			output.WriteUTF(Name);
+		}
+
+		public void FromData(DataInput input)
+		{
+			Width = input.ReadInt32();
+			Height = input.ReadInt32();
+			Name = input.ReadUTF();
+		}
+
+		public ulong ObjectSize
+		{
+			get { return 0; }
+		}
+
+		public static ISerializable CreateDeserializable()
+		{
+			return new TestClassB();
+		}
+
+		public override bool Equals(object obj)
+		{
+			if (obj == null)
+				return false;
+			if (obj == this)
+				return true;
+
+			var other = obj as TestClassB;
+
+			if (Width == other.Width &&
+				Name == other.Name &&
+				Height == other.Height)
+				return true;
+			else
+				return false;
+		}
+
+		public override int GetHashCode()
+		{
+			return base.GetHashCode();
+		}
+	}
+
+	public class TestClassC : IDataSerializable
+	{
+		public string Color { get; set; }
+		public string Make { get; set; }
+		public int Year { get; set; }
+
+		// A default constructor is required for deserialization
+		public TestClassC() { }
+
+		public TestClassC(string color, string make, int year)
+		{
+			Color = color;
+			Make = make;
+			Year = year;
+		}
+
+		public override string ToString()
+		{
+			return string.Format("TestClassC: [{0}, {1}, {2}]", Color, Make, Year);
+		}
+
+		public void ToData(DataOutput output)
+		{
+			output.WriteUTF(Color);
+			output.WriteUTF(Make);
+			output.WriteInt32(Year);
+		}
+
+		public void FromData(DataInput input)
+		{
+			Color = input.ReadUTF();
+			Make = input.ReadUTF();
+			Year = input.ReadInt32();
+		}
+
+		public ulong ObjectSize
+		{
+			get { return 0; }
+		}
+
+		public static ISerializable CreateDeserializable()
+		{
+			return new TestClassC();
+		}
+
+		public override bool Equals(object obj)
+		{
+			if (obj == null)
+				return false;
+			if (obj == this)
+				return true;
+
+			var other = obj as TestClassC;
+
+			if (Color == other.Color &&
+				Make == other.Make &&
+				Year == other.Year)
+				return true;
+			else
+				return false;
+		}
+
+		public override int GetHashCode()
+		{
+			return base.GetHashCode();
+		}
+	}
+
+	public class CompositeClass : IDataSerializable
+    {
+        private TestClassA testclassA;
+		private List<TestClassB> testclassBs;
+		private List<TestClassC> testclassCs;
+
+		public CompositeClass()
+		{
+			testclassA = new TestClassA();
+			testclassBs = new List<TestClassB>();
+			testclassCs = new List<TestClassC>();
+		}
+
+		public TestClassA A
+		{
+			get
+			{
+				return testclassA;
+			}
+			set
+			{
+				testclassA = value;
+			}
+		}
+
+		public List<TestClassB> Bs
+		{
+			get
+			{
+				return testclassBs;
+			}
+			set
+			{
+				testclassBs = value;
+			}
+		}
+
+		public List<TestClassC> Cs
+		{
+			get
+			{
+				return testclassCs;
+			}
+			set
+			{
+				testclassCs = value;
+			}
+		}
+
+		public void ToData(DataOutput output)
+		{
+			testclassA.ToData(output);
+			output.WriteObject(testclassBs);
+			output.WriteObject(testclassCs);
+		}
+
+		//private unsafe void fillstack(Int64[] val)
+		//{
+  //          return;
+		//}
+		public void FromData(DataInput input)
+		{
+			testclassA.FromData(input);
+
+			// Fill the stack with Order typeid: 66

Review comment:
       Fixed.




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



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

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #704:
URL: https://github.com/apache/geode-native/pull/704#discussion_r535362988



##########
File path: tests/javaobject/cli/TestClassC.java
##########
@@ -0,0 +1,114 @@
+/*
+ * 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();
+     }
+   });
+  }
+
+
+
+/*

Review comment:
       Fixed dead code in TestClassB.java and TestClassA.java.




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



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

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #704:
URL: https://github.com/apache/geode-native/pull/704#discussion_r535637639



##########
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:
       Good catch. I'm now aware of the (-) indicator. Final line feed added on the four 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



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

Posted by GitBox <gi...@apache.org>.
mmartell commented on a change in pull request #704:
URL: https://github.com/apache/geode-native/pull/704#discussion_r535535281



##########
File path: clicache/integration-test2/SerializationTests.cs
##########
@@ -510,5 +823,119 @@ public void PutGetCustomSerializableTypes()
                 cache.Close();
             }
         }
-    }
-}
+
+		[Fact]
+		public void CompositeClassWithClassAsKey()

Review comment:
       Added a new test ClassAsKey.




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