Comments (5)
The fix has been integrated
from one-nio.
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.
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.
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.
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)
- SharedMaps: how use correctly HOT 1
- HttpClient extra whitespace break Transfer-Encoding chunked header HOT 7
- Utf-8 support for 4 byte chars HOT 2
- JDK16 SelectableJavaSocket illegal reflective access HOT 2
- Java 17 is supported HOT 3
- Вэб-сокеты HOT 1
- java.time bug HOT 2
- java.util.Locale support HOT 2
- BigInteger problem HOT 2
- quic and http3 plans HOT 6
- BigDecimal with new Java does not work any more HOT 4
- json skip serialize default primitive values HOT 2
- json deserialization numbers to string HOT 1
- Unable to connect to https://api.kucoin.com due to javax.net.ssl.SSLException: error:0A000410:SSL routines::sslv3 alert handshake failure
- one-nio version >=1.6.1 doesn't work with glibc 2.31 HOT 1
- reactive-streams HOT 1
- ClassNotFoundException is not serializable for Adoptium jdk 17 HOT 1
- how to get a user's ip on a server using RPC? HOT 3
- Java 22 - error serialization and deserialization BigDecimal
- HttpClient: timeout per request HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from one-nio.