Skip to content
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

Improve configuration cache support for Java Object Serialization #13588

Open
Tracked by #28341
bamboo opened this issue Jun 25, 2020 · 4 comments
Open
Tracked by #28341

Improve configuration cache support for Java Object Serialization #13588

bamboo opened this issue Jun 25, 2020 · 4 comments

Comments

@bamboo
Copy link
Member

bamboo commented Jun 25, 2020

JavaObjectSerializationCodec allows objects that support the Java Object Serialization protocol to be stored in the configuration cache.

The implementation is currently limited to serializable classes that implement the java.io.Serializable interface
and define one of the following combination of methods:

  • a writeObject method combined with a readObject method to control exactly which information to store;
  • a writeObject method with no corresponding readObject; writeObject must eventually call ObjectOutputStream.defaultWriteObject;
  • a readObject method with no corresponding writeObject; readObject must eventually call ObjectInputStream.defaultReadObject;
  • a writeReplace method to allow the class to nominate a replacement to be written;
  • a readResolve method to allow the class to nominate a replacement for the object just read;

The following Java Object Serialization features are not supported:

  • serializable classes implementing the java.io.Externalizable interface; objects of such classes are discarded by the configuration cache during serialization and reported as problems;
  • the serialPersistentFields member to explicitly declare which fields are serializable; the member, if present, is ignored; the configuration cache considers all but transient fields serializable;
  • the following methods of ObjectOutputStream are not supported and will throw UnsupportedOperationException:
    • reset(), writeFields(), putFields(), writeChars(String), writeBytes(String) and writeUnshared(Any?).
  • the following methods of ObjectInputStream are not supported and will throw UnsupportedOperationException:
    • readLine(), readFully(ByteArray), readFully(ByteArray, Int, Int), readUnshared(), readFields(), transferTo(OutputStream) and readAllBytes().
  • validations registered via ObjectInputStream.registerValidation are simply ignored;
  • the readObjectNoData method, if present, is never invoked;
bamboo added a commit that referenced this issue Jun 25, 2020
Types that implement `java.io.Externalizable` are very unlikely to serialize
correctly to the configuration cache so failing eagerly on them is likely to
produce a simpler and more meaningful report.

See #13588
@bamboo bamboo changed the title Let configuration cache support java.io.Externalizable types Improve configuration cache support for Java Object Serialization Jul 6, 2020
@stale
Copy link

stale bot commented Apr 17, 2022

This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution.

@stale stale bot added the stale label Apr 17, 2022
@bamboo
Copy link
Member Author

bamboo commented Apr 18, 2022

This is still relevant.

@mgroth0
Copy link

mgroth0 commented Oct 31, 2022

Can we have some example code (in Kotlin) in the docs for how to create a custom class that is serializble by the configuration cache? Just having a minimal example with a few lines would be very helpful.

@SgtSilvio
Copy link

SgtSilvio commented Mar 11, 2024

Currently java.time.Instant cannot be used with the configuration cache, although it is Serializable, but it is replaced with java.time.Ser during serialization which is Externalizable.
Basically all types in the java.time package are affected.
Might be a reason to lift the restriction:

serializable classes implementing the java.io.Externalizable interface; objects of such classes are discarded by the configuration cache during serialization and reported as problems;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants