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

[Java] Object deep copy didn't handle transient fields correctly #1849

Open
1 of 2 tasks
chaokunyang opened this issue Sep 24, 2024 · 0 comments
Open
1 of 2 tasks

[Java] Object deep copy didn't handle transient fields correctly #1849

chaokunyang opened this issue Sep 24, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@chaokunyang
Copy link
Collaborator

chaokunyang commented Sep 24, 2024

Search before asking

  • I had searched in the issues and found no similar issues.

Version

main branch

Component(s)

Java

Minimal reproduce step

In org.apache.fury.serializer.AbstractObjectSerializer, we added transient fields for copy too. But not all fields are copyable. For example, we may have a transient field such as a Lock, it's will introduce subtle bugs if we copy such objects.

What did you expect to see?

We should copy non-transient and non-static fields only, and follow object serialization semantics.

AbstractObjectSerializer needs to change and all serializers which extends AbstractObjectSerializer needs to change to. We still need to following object serialization process, just skip writing data to buffer

What did you see instead?

transient fields are copied too.

Anything Else?

#1701
#1739

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@chaokunyang chaokunyang added the bug Something isn't working label Sep 24, 2024
@zhaommmmomo zhaommmmomo self-assigned this Nov 3, 2024
chaokunyang pushed a commit that referenced this issue Nov 4, 2024

## What does this PR do?
Adjusting the deep copy of ReplaceResolveSerializer.

obj -> writeReplace -> copy -> readResolve -> newObj

<!-- Describe the purpose of this PR. -->

## Related issues
#1849
<!--
Is there any related issue? Please attach here.

- #xxxx0
- #xxxx1
- #xxxx2
-->

## Does this PR introduce any user-facing change?

<!--
If any user-facing interface changes, please [open an
issue](https://github.com/apache/fury/issues/new/choose) describing the
need to do so and update the document if necessary.
-->

- [ ] Does this PR introduce any public API change?
- [ ] Does this PR introduce any binary protocol compatibility change?

## Benchmark

<!--
When the PR has an impact on performance (if you don't know whether the
PR will have an impact on performance, you can submit the PR first, and
if it will have impact on performance, the code reviewer will explain
it), be sure to attach a benchmark data here.
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants