diff options
author | Yuxuan 'fishy' Wang <yuxuan.wang@reddit.com> | 2021-04-27 19:56:58 -0700 |
---|---|---|
committer | Yuxuan 'fishy' Wang <fishywang@gmail.com> | 2021-04-28 18:49:58 -0700 |
commit | fe3f8a1279660b2e3a47798fa2c8a7bd6800e4e9 (patch) | |
tree | 04a582b268b2ac6d01d128850a42e398dabaff74 | |
parent | 80415f05d621c861aeaa791fa93a1c3bee8b84bc (diff) | |
download | thrift-fe3f8a1279660b2e3a47798fa2c8a7bd6800e4e9.tar.gz |
THRIFT-5404: Allow other types of TTransportException to be timeouts
Client: go
Currently we only treat TTransportException with typeId == TIMED_OUT as
timeout (return true in Timeout function). When opening a new socket, if
we got a connect timeout from net.Dial, we wrap the error as
TTransportException with typeId == NOT_OPEN, thus it's no longer treated
as a timeout error.
Change the error to be directly wrapping the original error (instead of
recreate a new error with the same error message), and change
tTransportException.Timeout to also return true if the wrapped error
is a timeout error. This way we don't have to break anything (if code
rely on TTransportException.TypeId being NOT_OPEN in this case, that's
still true).
While I'm here, also update CHANGES.md from #2359.
-rw-r--r-- | CHANGES.md | 3 | ||||
-rw-r--r-- | lib/go/thrift/socket.go | 6 | ||||
-rw-r--r-- | lib/go/thrift/ssl_socket.go | 12 | ||||
-rw-r--r-- | lib/go/thrift/transport_exception.go | 2 |
4 files changed, 18 insertions, 5 deletions
diff --git a/CHANGES.md b/CHANGES.md index 99123ba7a..5853312e2 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,7 +11,8 @@ ### Go -- [THRIFT-5369](https://issues.apache.org/jira/browse/THRIFT-5369) - No longer pre-allocating the whole container (map/set/list) in compiled go code to avoid huge allocations on malformed messages +- [THRIFT-5369](https://issues.apache.org/jira/browse/THRIFT-5369) - TConfiguration.GetMaxMessageSize() now also applies to container sizes in TProtocol implementations provided +- [THRIFT-5404](https://issues.apache.org/jira/browse/THRIFT-5404) - TTransportException.Timeout would correctly return true when it's connect timeout during TSocket.Open call ## 0.14.1 diff --git a/lib/go/thrift/socket.go b/lib/go/thrift/socket.go index e911bf166..0cf59a0f5 100644 --- a/lib/go/thrift/socket.go +++ b/lib/go/thrift/socket.go @@ -166,7 +166,11 @@ func (p *TSocket) Open() error { p.addr.String(), p.cfg.GetConnectTimeout(), )); err != nil { - return NewTTransportException(NOT_OPEN, err.Error()) + return &tTransportException{ + typeId: NOT_OPEN, + err: err, + msg: err.Error(), + } } return nil } diff --git a/lib/go/thrift/ssl_socket.go b/lib/go/thrift/ssl_socket.go index 6359a74ce..cd711fffe 100644 --- a/lib/go/thrift/ssl_socket.go +++ b/lib/go/thrift/ssl_socket.go @@ -167,7 +167,11 @@ func (p *TSSLSocket) Open() error { p.hostPort, p.cfg.GetTLSConfig(), )); err != nil { - return NewTTransportException(NOT_OPEN, err.Error()) + return &tTransportException{ + typeId: NOT_OPEN, + err: err, + msg: err.Error(), + } } } else { if p.conn.isValid() { @@ -190,7 +194,11 @@ func (p *TSSLSocket) Open() error { p.addr.String(), p.cfg.GetTLSConfig(), )); err != nil { - return NewTTransportException(NOT_OPEN, err.Error()) + return &tTransportException{ + typeId: NOT_OPEN, + err: err, + msg: err.Error(), + } } } return nil diff --git a/lib/go/thrift/transport_exception.go b/lib/go/thrift/transport_exception.go index 0a3f07646..a51510ed9 100644 --- a/lib/go/thrift/transport_exception.go +++ b/lib/go/thrift/transport_exception.go @@ -72,7 +72,7 @@ func (p *tTransportException) Unwrap() error { } func (p *tTransportException) Timeout() bool { - return p.typeId == TIMED_OUT + return p.typeId == TIMED_OUT || isTimeoutError(p.err) } func NewTTransportException(t int, e string) TTransportException { |