diff --git a/release-notes/CREDITS-2.x b/release-notes/CREDITS-2.x index 3c39a958..363b384b 100644 --- a/release-notes/CREDITS-2.x +++ b/release-notes/CREDITS-2.x @@ -33,6 +33,7 @@ WrongWrong (@k163377) * #652: Deletion of unused methods. * #654: Change MKPE.parameter property to transient. * #659: Improve serialization support for value class. +* #665: Modified to not load the entire Sequence into memory during serialization. Sylvain-maillard (@Sylvain-maillard) * #554: Add extension function for addMixin. diff --git a/release-notes/VERSION-2.x b/release-notes/VERSION-2.x index cbec876e..601fe25d 100644 --- a/release-notes/VERSION-2.x +++ b/release-notes/VERSION-2.x @@ -49,6 +49,8 @@ Co-maintainers: Fixes #618 and partially fixes #625. Also fixed is serialization when a getter-like function returns a value class, and behavior when a getter is annotated with a `JsonSerialize` annotation. (contributed by wrongwrong) +#665: Modified to not load the entire Sequence into memory during serialization(fixes #368). + (contributed by wrongwrong) It is also confirmed that the issue submitted below is no longer reproduced, although it is unclear when it was explicitly fixed. diff --git a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinSerializers.kt b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinSerializers.kt index 056c70dd..d03eb601 100644 --- a/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinSerializers.kt +++ b/src/main/kotlin/com/fasterxml/jackson/module/kotlin/KotlinSerializers.kt @@ -15,8 +15,7 @@ import java.math.BigInteger object SequenceSerializer : StdSerializer>(Sequence::class.java) { override fun serialize(value: Sequence<*>, gen: JsonGenerator, provider: SerializerProvider) { - val materializedList = value.toList() - provider.defaultSerializeValue(materializedList, gen) + provider.defaultSerializeValue(value.iterator(), gen) } }