Giter Club home page Giter Club logo

Comments (5)

apangin avatar apangin commented on May 26, 2024 2

The fix has been integrated

from one-nio.

apangin avatar apangin commented on May 26, 2024

Hi @genuss. Yes, java.time.* serialization is a known problem which I plan to fix.

Unfortunately, implementing writeReplace/readResolve in a generic way is not as trivial as one may think. Resolving inner references within an object graph may be problematic, since the referenced object doesn't yet exist before the full graph is deserialized and readResolve is called.

SKIP_READ_OBJECT option for all java.time.* classes or for the whole java.time package at once is a viable solution. However, this will result in a bigger overhead for some objects comparing to standard Java serialization. E.g. LocalDateTime will take extra 16 bytes for LocalDate and LocalTime headers. This is not a big problem though.

Another option I consider is a white-list support for writeReplace/readResolve (e.g. enable them for the known "good" classes). Finally, there is always a last resort solution to add a custom serializer for java.time* classes. If you have other ideas, please let me know.

from one-nio.

genuss avatar genuss commented on May 26, 2024

Well my first thought was to implement custom serializers for needed classes. This method has downsides because it's too much hand work and it's not easy to support in long-term.
Enabling SKIP_READ_OBJECT was my second thought and it looks like good solution for most cases. If we combine custom serializers idea with this one, we won't get the size overhead.

Could clarify why generic way is not that trivial? From my point of view Serializer is generated at serialization phase not at deserialization on which we have all needed information about class and fields of serialized instance.

from one-nio.

apangin avatar apangin commented on May 26, 2024

I mean, runtime object graph may have the same object serialized multiple times. Furthermore, an object may refer to itself either directly or through a chain of references. This needs to be deserialized correctly. DeserializeStream.context solves this problem, but it does not work for serialization proxy.

from one-nio.

genuss avatar genuss commented on May 26, 2024

Thank you, I see now what you mean. Looks like there is no obvious solution, but I will try to dig in.
At least SKIP_READ_OBJECT is a reasonable workaround for now.

from one-nio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.