-
Notifications
You must be signed in to change notification settings - Fork 246
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
feat(java): support Ignore inconsistent types deserialize #1737
Conversation
} | ||
// Make DescriptorGrouper have consistent order whether field exist or not | ||
// type is inconsistent use serialize type, except enum | ||
if (!newDesc.getRawType().isAssignableFrom(descriptor.getRawType()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!newDesc.getRawType().isAssignableFrom(descriptor.getRawType()) | |
if (!descriptor.getRawType().isAssignableFrom(newDesc.getRawType()) |
descriptors.add(newDesc); | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete this line
// Make DescriptorGrouper have consistent order whether field exist or not | ||
// type is inconsistent use serialize type, except enum | ||
if (!newDesc.getRawType().isAssignableFrom(descriptor.getRawType()) | ||
&& !descriptor.getRawType().isEnum()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this check first
} | ||
descriptor = descriptor.copyWithTypeName(newDesc.getTypeName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add else
here
@@ -160,4 +163,53 @@ public void testEmptyObject() { | |||
Fury fury = Fury.builder().requireClassRegistration(true).build(); | |||
assertSame(serDe(fury, new Object()).getClass(), Object.class); | |||
} | |||
|
|||
@Test | |||
public void testIgnoreTypeInconsistentSerializer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put this to MetaSharedObjectSerializerTest
java/fury-core/src/main/java/org/apache/fury/meta/ClassDef.java
Outdated
Show resolved
Hide resolved
descriptor = descriptor.copyWithTypeName(newDesc.getTypeName()); | ||
descriptors.add(descriptor); | ||
// fury builtin types skip | ||
if (newDesc.getRawType().getTypeName().contains("apache.fury") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
newDesc.getRawType().getTypeName().contains("apache.fury")
looks too hack, this should be removed
|| newDesc.getRawType().isAssignableFrom(descriptor.getRawType())) { | ||
if (newDesc.getRawType().isEnum() | ||
|| newDesc.getRawType().isAssignableFrom(descriptor.getRawType()) | ||
|| newDesc.getRawType().isAssignableFrom(NonexistentClass.NonexistentEnum.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use org.apache.fury.serializer.NonexistentClass#isNonexistent
instead
descriptor = descriptor.copyWithTypeName(newDesc.getTypeName()); | ||
descriptors.add(descriptor); | ||
// fury builtin types skip | ||
if (newDesc.getRawType().isEnum() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make newDesc.getRawType() as a local variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What does this PR do?
Related issues
Does this PR introduce any user-facing change?
Benchmark