Skip to content

Commit 18454bb

Browse files
committed
Adjust default typing section
Adjust the default typing section, as using the default type operation on the ObjectMapper may be an ensecure operation. Hence, we should steer towards usages of the JsonTypeInfor first.
1 parent ad92a1a commit 18454bb

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

axon-framework/serialization.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,21 @@ public class SerializerConfiguration {
193193
{% endtab %}
194194
{% endtabs %}
195195

196-
### Default Typing
196+
### Generic Types
197197

198198
Sometimes the objects serialized by Axon will contain lists or collections of data.
199+
In other words, objects containing generics.
199200
For XStream, this poses no problem, as it will automatically add the type information to the serialized format.
200201
Jackson does not do this out of the box, however.
201202

202-
You can configure the `ObjectMapper` to add default typing information, but the `JacksonSerializer's` builder also provides a method to enable this for you.
203+
The recommended approach by Jackson is to use the `@JsonTypeInfo` to define type information.
204+
Doing so will attach the object type to your, for example, serialized list/collection.
205+
This approach ensures that the other end can reconstruct the concrete type for you.
206+
207+
Additionally, you can configure the `ObjectMapper` to add default typing information directly.
208+
However, note that this may not be a secure approach, as is described on Jackson's [Polymorphic Deserialization](https://github.com/FasterXML/jackson-docs/wiki/JacksonPolymorphicDeserialization) page.
209+
210+
If you prefer to enable default typing regardless, the `JacksonSerializer's` builder provides a method to allow this for you.
203211
With `JacksonSerializer.Builder#defaultTyping`, you will automatically enable the addition of types to the serialized format for lists and collections.
204212
Consider the following sample on how to enable default typing for the `JacksonSerializer`:
205213

0 commit comments

Comments
 (0)