You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Michael Smith (Jira)" <ji...@apache.org> on 2025/11/14 20:50:00 UTC

[jira] [Assigned] (THRIFT-792) TSocket hides underlying exceptions when open() fails

     [ https://issues.apache.org/jira/browse/THRIFT-792?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Michael Smith reassigned THRIFT-792:
------------------------------------

    Assignee: Michael Smith

> TSocket hides underlying exceptions when open() fails 
> ------------------------------------------------------
>
>                 Key: THRIFT-792
>                 URL: https://issues.apache.org/jira/browse/THRIFT-792
>             Project: Thrift
>          Issue Type: Bug
>          Components: Python - Library
>    Affects Versions: 0.2
>         Environment: Linux & Python 2.6
>            Reporter: tholzer
>            Assignee: Michael Smith
>            Priority: Major
>              Labels: TSocket, connect, error, exception, open, socket
>
> When opening a socket via Thrift, the exception message simply says:
> "Could not connect to localhost:9160"
> The underlying OS error is lost. This is a classic example of the anti-pattern called "exception masquerading". The exception handler loses essential information related to the source of the error. This makes troubleshooting difficult.
> The problem lies inside TSocket.py, the original socket.error is simply discarded:
> {noformat} 
> try:
>   ... connect() ...
> except socket.error, e:
>       ...
>       message = 'Could not connect to %s:%d' % (self.host, self.port)
>       raise TTransportException(TTransportException.NOT_OPEN, message)
> {noformat} 
> To reproduce
> {noformat}thrift.transport.TSocket.TSocket().open(){noformat} 
> Excpected behaviour:
> The TTransportException should carry as much information as possible relating to the original error, e.g.:
> Could not connect to (localhost:9090): (<class 'socket.error'>, error(111, 'Connection refused'))
> The TTransportException should carry the real exception it was trying to hide as a member variable so that the caller can take appropriate action in case of transient failures (e.g. EINTR).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)