[
https://issues.apache.org/jira/browse/THRIFT-4215?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16034622#comment-16034622
]
ASF GitHub Bot commented on THRIFT-4215:
----------------------------------------
GitHub user dcelasun opened a pull request:
https://github.com/apache/thrift/pull/1285
THRIFT-4215/4216 Make transport factories return errors
This commit changes the signature of `TTransportFactory.GetTransport` from
```go
GetTransport(trans TTransport) TTransport
```
to
```go
GetTransport(trans TTransport) (TTransport, error)
```
so the factory can pass any underlying error to the caller (previously such
errors were ignored).
This is a backwards incompatible change for anyone implementing custom
transports, but it shouldn't effect anyone using the ones in this library.
Fixes [THRIFT-4215](https://issues.apache.org/jira/browse/THRIFT-4215).
Fixes [THRIFT-4216](https://issues.apache.org/jira/browse/THRIFT-4216).
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/dcelasun/thrift THRIFT-4215
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/thrift/pull/1285.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1285
----
commit 312a4aadbb2106c9fb21360b87e0c2d5fea8a78e
Author: D. Can Celasun <[email protected]>
Date: 2017-06-02T12:33:32Z
THRIFT-4215 Make transport factories return errors
This commit changes the signature of TTransportFactory.GetTransport
from
GetTransport(trans TTransport) TTransport
to
GetTransport(trans TTransport) (TTransport, error)
so the factory can pass any underlying error to the caller (previously
such errors were ignored).
This is a backwards incompatible change for anyone implementing custom
transports, but it shouldn't effect anyone using the ones in this
library.
Fixes THRIFT-4215.
Fixes THRIFT-4216.
----
> Golang TTransportFactory Pattern Squelches Errors
> -------------------------------------------------
>
> Key: THRIFT-4215
> URL: https://issues.apache.org/jira/browse/THRIFT-4215
> Project: Thrift
> Issue Type: Bug
> Components: Go - Library
> Affects Versions: 0.10.0
> Reporter: James Mouradian
> Assignee: Can Celasun
>
> The current (as of 72ca60d) pattern for [TTransport
> factories|https://github.com/apache/thrift/blob/master/lib/go/thrift/transport_factory.go#L26]
> in Golang is
> {code}
> type TTransportFactory interface {
> GetTransport(trans TTransport) TTransport
> }
> {code}
> This causes issues, because some {{TTransportFactory}} implementations can
> return and error. Consider the
> [THttpClientTransportFactory|https://github.com/apache/thrift/blob/master/lib/go/thrift/http_client.go#L52],
> which as of of 72ca60d, includes the following snippet:
>
> {code}
> s, _ := NewTHttpClientWithOptions(p.url, p.options)
> return s
> {code}
> The call to {{NewTHttpClientWithOptions(...)}} call can throw errors. The
> resultant behavior is that {{nil}} is returned in place of a valid
> {{TTransport}}, with a {{nil}} error.
> The {{TTransportFactory}} interface (and associated use patterns) should be
> extended to include errors.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)