[ https://issues.apache.org/jira/browse/THRIFT-5845?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Yuxuan Wang updated THRIFT-5845: -------------------------------- Description: Currently, when writing an union field and not exactly one field of the union is set, we just return a generic error: {code:go} return fmt.Errorf("%T write union: exactly one field must be set (%d set)", p, c) {code} This makes it very hard for logic like client pool management to decide whether a connection can be reused after an error. Making it return a TTransportException would resolve the issue. But with the codes of TTransportException none is appropriate (the codes are: NOT_OPEN, ALREADY_OPEN, TIMED_OUT, END_OF_FILE), so maybe use TProtocolException with INVALID_DATA instead. was: Currently, when writing an union field and not exactly one field of the union is set, we just return a generic error: {code:go} return fmt.Errorf("%T write union: exactly one field must be set (%d set)", p, c) {code} This makes it very hard for logic like client pool management to decide whether a connection can be reused after an error. Making it return a TTransportException would resolve the issue. > The write error for union fields should be TException > ----------------------------------------------------- > > Key: THRIFT-5845 > URL: https://issues.apache.org/jira/browse/THRIFT-5845 > Project: Thrift > Issue Type: Task > Components: Go - Compiler > Affects Versions: 0.21.0 > Reporter: Yuxuan Wang > Assignee: Yuxuan Wang > Priority: Major > > Currently, when writing an union field and not exactly one field of the union > is set, we just return a generic error: > {code:go} > return fmt.Errorf("%T write union: exactly one field must be set (%d set)", > p, c) > {code} > This makes it very hard for logic like client pool management to decide > whether a connection can be reused after an error. Making it return a > TTransportException would resolve the issue. > But with the codes of TTransportException none is appropriate (the codes are: > NOT_OPEN, ALREADY_OPEN, TIMED_OUT, END_OF_FILE), so maybe use > TProtocolException with INVALID_DATA instead. -- This message was sent by Atlassian Jira (v8.20.10#820010)