-
Notifications
You must be signed in to change notification settings - Fork 614
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
Polymorphic default serializer does not affect serialization #1317
Comments
This seems similar to #1276 and it's PR, but for polymorphism instead of contextual serialization, and as such I don't think it's fix will work here. |
I'm willing to make a PR for this, if the design is approved. I'd make a second |
This should be a feature request for default serializers to apply for serialization, since I just found the docs saying |
Yes, |
I'm working with Java APIs so I can't register subclasses without classpath scanning or other trickery. If I have |
+1 on this issue, I am trying to serialize a Java interface that has only one implementation class. Since that class is private, I can't explicitly register a serializer for it. I'd prefer not to annotate everything with |
+1 on this issue. To add another perspective on this issue: in my case, there are many implementations of an interface for which I can easily derive a serializer, but registering all subclasses is not only tedious but also brittle. |
Thanks for the updates on use-cases, we'll revisit this issue |
Fixed by #1686 |
Describe the bug
I have an interface
Operand
, and I'm trying to serialize allOperand
instances using a certain serializer. This seems pretty straightforward, I can use a module withpolymorphicDefault(Operand::class){ serializer }
. However, when I run it, I get:Looking at the code, it seems like this might be because the
SerialModuleImpl#getPolymorphic
that takes the value never referencespolyBase2DefaultProvider
, only the one that takes the string does.It may have to do with
polymorphicDefault
being intended for deserialization only, but I'd like to use it for serialization as well.To Reproduce
(I'm aware this is bad practice for serializing stuff, and I don't have access to the real
Operand
andConstant
classes (they are Java classes))Expected behavior
The
OperandSerializer
is used forOperand
values.Environment
The text was updated successfully, but these errors were encountered: