|
| 1 | +From f44f148bb9cff81f320e7094e7956d98fc5ac423 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Stepan Blyschak < [email protected]> |
| 3 | +Date: Wed, 20 Mar 2019 16:32:56 +0200 |
| 4 | +Subject: [PATCH] Revert "THRIFT-3650 incorrect union serialization" |
| 5 | + |
| 6 | +This reverts commit b72bb94a8212edc83864edc435896fdcda6e796c. |
| 7 | + |
| 8 | +Signed-off-by: Stepan Blyschak < [email protected]> |
| 9 | +--- |
| 10 | + compiler/cpp/src/thrift/parse/t_struct.h | 16 ++++++---------- |
| 11 | + 1 file changed, 6 insertions(+), 10 deletions(-) |
| 12 | + |
| 13 | +diff --git a/compiler/cpp/src/thrift/parse/t_struct.h b/compiler/cpp/src/thrift/parse/t_struct.h |
| 14 | +index 4102da7..880e79b 100644 |
| 15 | +--- a/compiler/cpp/src/thrift/parse/t_struct.h |
| 16 | ++++ b/compiler/cpp/src/thrift/parse/t_struct.h |
| 17 | +@@ -66,16 +66,12 @@ public: |
| 18 | + void validate_union_member(t_field* field) { |
| 19 | + if (is_union_ && (!name_.empty())) { |
| 20 | + |
| 21 | +- // 1) unions can't have required fields |
| 22 | +- // 2) union members are implicitly optional, otherwise bugs like THRIFT-3650 wait to happen |
| 23 | +- if (field->get_req() != t_field::T_OPTIONAL) { |
| 24 | +- // no warning on default requiredness, but do warn on anything else that is explicitly asked for |
| 25 | +- if(field->get_req() != t_field::T_OPT_IN_REQ_OUT) { |
| 26 | +- pwarning(1, |
| 27 | +- "Union %s field %s: union members must be optional, ignoring specified requiredness.\n", |
| 28 | +- name_.c_str(), |
| 29 | +- field->get_name().c_str()); |
| 30 | +- } |
| 31 | ++ // unions can't have required fields |
| 32 | ++ if (field->get_req() == t_field::T_REQUIRED) { |
| 33 | ++ pwarning(1, |
| 34 | ++ "Required field %s of union %s set to optional.\n", |
| 35 | ++ field->get_name().c_str(), |
| 36 | ++ name_.c_str()); |
| 37 | + field->set_req(t_field::T_OPTIONAL); |
| 38 | + } |
| 39 | + |
| 40 | +-- |
| 41 | +1.9.1 |
| 42 | + |
0 commit comments