Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix compatible field serializer binary search bugs #539

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public T read (Kryo kryo, Input input, Class<T> type) {
// binary search for schemaName
int low, mid, high;
int compare;
int maxFieldLength = allFields.length > length ? allFields.length : length;
int maxFieldLength = allFields.length;
outerBinarySearch:
for (int i = 0; i < length; i++) {
String schemaName = names[i];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,15 @@ public void testRemovedFieldFromClassWithManyFields () throws FileNotFoundExcept

CompatibleFieldSerializer serializer = new CompatibleFieldSerializer(kryo, ClassWithManyFields.class);
serializer.removeField("bAdd");
serializer.removeField("zz");
kryo.register(ClassWithManyFields.class, serializer);
Object object2 = kryo.readClassAndObject(input);
assertTrue(object2 instanceof ClassWithManyFields);
assertNull("the bAdd field should be null", ((ClassWithManyFields) object2).bAdd);
assertNull("the zz field should be null", ((ClassWithManyFields) object2).zz);
// update the field in order to verify the remainder of the object was deserialized correctly
((ClassWithManyFields) object2).bAdd = object1.bAdd;
((ClassWithManyFields) object2).zz = object1.zz;
assertEquals(object1, object2);
}

Expand Down