Commit 407323f
Fix
`Any` `value` field is a `bytes` field in OSS, and since cl/792909628 (#22956), `_internal_mutable_*()` accessors for string fields don't set hasbits. This can cause the hasbit to be missing for the `value` field of `Any` after calling `PackFrom`, which will serialize incorrectly.
This change also includes fixes to `any_test`, which failed to catch this bug. We got unlucky, and every test which checked a roundtrip `PackFrom` -> `UnpackTo` for an `Any` field reused the same `Any` object, calling `MessageLite::ParseFromString` (which `Clear()`s it) on the same object. However, `Clear()` skips string fields whose hasbits are not set. This meant the `string value` field of the `Any` was not cleared, since its hasbit had not been properly set by `PackFrom`. So even though the `Any` value skipped serializing its value, the reused `Any` object still contained the expected `string value` serialization of the submessage, and `UnpackTo` worked correctly.
The culprit change was adopted in release 33.0, so it will need to be patched to this version.
See #24258.
Fixes #24258
PiperOrigin-RevId: 828299368Any hasbit consistency issue in OSS.1 parent 12a8943 commit 407323f
2 files changed
+60
-50
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 | | |
| 39 | + | |
36 | 40 | | |
37 | 41 | | |
38 | | - | |
| 42 | + | |
39 | 43 | | |
40 | 44 | | |
41 | 45 | | |
| |||
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
74 | 81 | | |
| 82 | + | |
75 | 83 | | |
76 | 84 | | |
77 | | - | |
78 | | - | |
| 85 | + | |
79 | 86 | | |
| 87 | + | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
83 | 91 | | |
84 | 92 | | |
85 | | - | |
86 | | - | |
87 | 93 | | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
97 | 107 | | |
98 | 108 | | |
99 | | - | |
| 109 | + | |
100 | 110 | | |
101 | 111 | | |
102 | 112 | | |
| |||
127 | 137 | | |
128 | 138 | | |
129 | 139 | | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | 140 | | |
134 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
135 | 146 | | |
136 | 147 | | |
137 | 148 | | |
138 | 149 | | |
139 | 150 | | |
140 | | - | |
| 151 | + | |
141 | 152 | | |
142 | 153 | | |
143 | 154 | | |
144 | 155 | | |
145 | 156 | | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | 157 | | |
150 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
151 | 163 | | |
152 | 164 | | |
153 | 165 | | |
154 | 166 | | |
155 | 167 | | |
156 | 168 | | |
157 | | - | |
| 169 | + | |
158 | 170 | | |
159 | 171 | | |
160 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1799 | 1799 | | |
1800 | 1800 | | |
1801 | 1801 | | |
1802 | | - | |
1803 | | - | |
| 1802 | + | |
1804 | 1803 | | |
1805 | 1804 | | |
1806 | 1805 | | |
1807 | 1806 | | |
1808 | 1807 | | |
1809 | 1808 | | |
1810 | | - | |
| 1809 | + | |
1811 | 1810 | | |
1812 | 1811 | | |
1813 | 1812 | | |
| |||
1825 | 1824 | | |
1826 | 1825 | | |
1827 | 1826 | | |
1828 | | - | |
| 1827 | + | |
1829 | 1828 | | |
1830 | 1829 | | |
1831 | 1830 | | |
1832 | 1831 | | |
1833 | 1832 | | |
1834 | 1833 | | |
1835 | 1834 | | |
1836 | | - | |
1837 | | - | |
1838 | | - | |
| 1835 | + | |
| 1836 | + | |
| 1837 | + | |
1839 | 1838 | | |
1840 | 1839 | | |
1841 | 1840 | | |
| |||
1851 | 1850 | | |
1852 | 1851 | | |
1853 | 1852 | | |
1854 | | - | |
1855 | | - | |
| 1853 | + | |
1856 | 1854 | | |
1857 | 1855 | | |
1858 | 1856 | | |
1859 | 1857 | | |
1860 | 1858 | | |
1861 | 1859 | | |
1862 | | - | |
| 1860 | + | |
1863 | 1861 | | |
1864 | 1862 | | |
1865 | 1863 | | |
| |||
0 commit comments