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 15:49:00 UTC

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

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