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

Inconsistency occurs in Java Proto builder when calling build() after clear() #10624

Closed
choxsword opened this issue Sep 20, 2022 · 17 comments
Closed
Assignees
Labels
inactive Denotes the issue/PR has not seen activity in the last 90 days. java

Comments

@choxsword
Copy link

choxsword commented Sep 20, 2022

After calling builder() after clear() of Pb builer , the consistency of isClean in message builder may break up. Here is the code snippet example.

We can see that finally the result printed is inconsistent between test3 and its subfield test1. And the reason is that build() operation does not mark those clear()ed child fields as isClean. This problem causes child field to be dirty, while parent is clean


//      package CsVip;
//        message test1{
//            optional int32 tt = 1;
//        }
//
//        message test2{
//            optional test1 t1 = 1;
//        }
//
//        message test3{
//            optional test2 t2 = 1;
//        }

    public static void main(String[] args) {

//testpb dirty  t2 dirty  t1 clean              testpb dirty t2 dirty t1 dirty
        CsVip.test3.Builder testpb = CsVip.test3.newBuilder();
        testpb.getT2Builder().getT1Builder(); //after: testpb dirty  t2 dirty  t1 clean
        testpb.getT2Builder().clear(); //after: testpb dirty t2 dirty t1 dirty
        testpb.getT2Builder().build();// t2 is still dirty ,but t1 is already clean , broke consistency
        testpb.build();//after: testpb dirty t2 clean t1 dirty

        testpb.getT2Builder().setT1(CsVip.test1.newBuilder().setTt(1).build());

        LOGGER.error("testpb {}", testpb);//output: t2 {}

        LOGGER.error("get T1 builder {}", testpb.getT2Builder().getT1Builder());
        LOGGER.error("testpb {}", testpb);//output: t2 {t1 {tt: 1}}

    }
@choxsword choxsword added the untriaged auto added to all issues by default when created. label Sep 20, 2022
@choxsword choxsword changed the title build() after clear create inconsistency in Proto builder Inconsistency occurs in Proto builder when calling build() after clear() Sep 20, 2022
@choxsword choxsword changed the title Inconsistency occurs in Proto builder when calling build() after clear() Inconsistency occurs in Java Proto builder when calling build() after clear() Sep 20, 2022
@shaod2 shaod2 added java and removed untriaged auto added to all issues by default when created. labels Sep 20, 2022
@choxsword
Copy link
Author

@googleberg Is there any progress with this bug?

@googleberg
Copy link
Member

@choxsword I can see the behavior you describe, but I'm curious what negative impact you see from the inconsistency.

@googleberg
Copy link
Member

@choxsword nm, I think I see what you are saying now. It creates a stale cache problem.

@choxsword
Copy link
Author

choxsword commented Oct 8, 2022

@choxsword nm, I think I see what you are saying now. It creates a stale cache problem.

Will fixing this issue be taken into consideration in future version?

@choxsword
Copy link
Author

@googleberg hey bro! Is there any plan of this issue?

@choxsword
Copy link
Author

@googleberg looking forward to you reply!

@googleberg
Copy link
Member

Hi @choxsword, yes, I have a fix for this, it won't be in the next release, but the one after.

@choxsword
Copy link
Author

@googleberg thanks a lot. plz call me if that release is published.

@choxsword
Copy link
Author

@googleberg hey, I'm wondering about which time will that release be published?

googleberg added a commit that referenced this issue Nov 14, 2022
Omitting this step was leading to stale cached versions of nested messages.
See #10624
googleberg added a commit that referenced this issue Nov 14, 2022
This will be used in verfication of #10624
googleberg added a commit that referenced this issue Nov 14, 2022
@choxsword
Copy link
Author

@googleberg thanks for your timly support! I've seen the fix for this issus. By the way, how long will it take for me to see a official
Protobuf Release with the newest update?

@googleberg
Copy link
Member

@choxsword The fix for this should be in the next release.

@choxsword
Copy link
Author

@googleberg when will next release be published? The newest version is the v21.9 relesase published one month ago.

@googleberg
Copy link
Member

The 21.10 release was delayed from the week of 2022/11/14 to next week (of 2022/11/28)

@choxsword
Copy link
Author

@googleberg Execuse me, is that release delayed again?

@googleberg
Copy link
Member

it is in progress.

srowen pushed a commit to apache/spark that referenced this issue Feb 20, 2023
### What changes were proposed in this pull request?
This pr aims upgrade `protobuf-java` from 3.21.12 to 3.22.0

### Why are the changes needed?
The new version bring some improvements like:

- Use bit-field int values in buildPartial to skip work on unset groups of fields. (protocolbuffers/protobuf@2326aef)
- Fix serialization warnings in generated code when compiling with Java 18 and above (protocolbuffers/protobuf#10561)
- Enable Text format parser to skip unknown short-formed repeated fields. (protocolbuffers/protobuf@6dbd413)
- Add serialVersionUID to ByteString and subclasses (protocolbuffers/protobuf#10718)

and some bug fix like:
- Mark default instance as immutable first to avoid race during static initialization of default instances. (protocolbuffers/protobuf#10770)

- Fix Timestamps fromDate for negative 'exact second' java.sql.Timestamps (protocolbuffers/protobuf#10321)
- Fix Timestamps.fromDate to correctly handle java.sql.Timestamps before unix epoch (protocolbuffers/protobuf#10126)
- Fix bug in nested builder caching logic where cleared sub-field builders would remain dirty after a clear and build in a parent layer. protocolbuffers/protobuf#10624

The release notes as follows:

- https://github.com/protocolbuffers/protobuf/releases/tag/v22.0

### Does this PR introduce _any_ user-facing change?
No

### How was this patch tested?
Pass GitHub Actions

Closes #40084 from LuciferYang/SPARK-42490.

Authored-by: yangjie01 <yangjie01@baidu.com>
Signed-off-by: Sean Owen <srowen@gmail.com>
Copy link

github-actions bot commented Jan 1, 2024

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please add a comment.

This issue is labeled inactive because the last activity was over 90 days ago.

@github-actions github-actions bot added the inactive Denotes the issue/PR has not seen activity in the last 90 days. label Jan 1, 2024
Copy link

We triage inactive PRs and issues in order to make it easier to find active work. If this issue should remain active or becomes active again, please reopen it.

This issue was closed and archived because there has been no new activity in the 14 days since the inactive label was added.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 17, 2024
dand-oss pushed a commit to dand-oss/protobuf that referenced this issue Mar 6, 2024
Omitting this step was leading to stale cached versions of nested messages.
See protocolbuffers#10624
dand-oss pushed a commit to dand-oss/protobuf that referenced this issue Mar 6, 2024
dand-oss pushed a commit to dand-oss/protobuf that referenced this issue Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inactive Denotes the issue/PR has not seen activity in the last 90 days. java
Projects
None yet
Development

No branches or pull requests

3 participants