protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

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

Open choxsword opened this issue 3 years ago • 7 comments

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 avatar Sep 20 '22 05:09 choxsword

@googleberg Is there any progress with this bug?

choxsword avatar Sep 30 '22 15:09 choxsword

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

googleberg avatar Sep 30 '22 17:09 googleberg

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

googleberg avatar Sep 30 '22 18:09 googleberg

@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 avatar Oct 08 '22 10:10 choxsword

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

choxsword avatar Oct 11 '22 07:10 choxsword

@googleberg looking forward to you reply!

choxsword avatar Oct 17 '22 03:10 choxsword

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

googleberg avatar Oct 18 '22 02:10 googleberg

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

choxsword avatar Nov 02 '22 02:11 choxsword

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

choxsword avatar Nov 07 '22 02:11 choxsword

@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?

choxsword avatar Nov 15 '22 08:11 choxsword

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

googleberg avatar Nov 15 '22 16:11 googleberg

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

choxsword avatar Nov 25 '22 05:11 choxsword

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

googleberg avatar Nov 26 '22 18:11 googleberg

@googleberg Execuse me, is that release delayed again?

choxsword avatar Nov 30 '22 03:11 choxsword

it is in progress.

googleberg avatar Nov 30 '22 05:11 googleberg

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[bot] avatar Jan 01 '24 10:01 github-actions[bot]

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[bot] avatar Jan 17 '24 10:01 github-actions[bot]