You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Bryan Duxbury (JIRA)" <ji...@apache.org> on 2009/05/27 17:46:46 UTC

[jira] Commented: (THRIFT-517) TExceptions thrown by server result in cryptic error message on client - Tried to read 4 bytes, but only got 0 bytes

    [ https://issues.apache.org/jira/browse/THRIFT-517?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12713610#action_12713610 ] 

Bryan Duxbury commented on THRIFT-517:
--------------------------------------

If you throw an anonymous TException on the server side, it's basically an "unexpected" exception. The way that the Thrift server code handles this is to log the exception and close the client connection. This is why your clientside gets a transport exception - the pipe closed on it unexpectedly.

We could consider actually sending back the exception message from the TException you threw, but that is a little iffy. Without declaring that a method throws a certain exception type, how do we know what to encode it as on the wire? If we wanted to do this, we would probably have to extend the message-passing layer to include an undeclared exception message. 

I think that in principle, if you are going to throw an exception, declare it. Otherwise the semantics are just too confusing. 

> TExceptions thrown by server result in cryptic error message on client - Tried to read 4 bytes, but only got 0 bytes
> --------------------------------------------------------------------------------------------------------------------
>
>                 Key: THRIFT-517
>                 URL: https://issues.apache.org/jira/browse/THRIFT-517
>             Project: Thrift
>          Issue Type: Bug
>          Components: Compiler (Java), Library (Java)
>            Reporter: Adrian Woodhead
>
> To reproduce:
> 1. Define a simple Thrift service method with no custom exceptions.
> 2. In server implementation of service method, throw a TException.
> 3. Generated code in client forces you to do try/catch TException around service call, do this, and output stack trace,
> The exception thrown by the server then results in this rather cryptic error message in the client:
> 26 22:32:44,931 INFO Caused by: org.apache.thrift.transport.TTransportException: Cannot read. Remote side has closed. Tried to read 4 bytes, but only got 0 bytes.
> 26 22:32:44,931 INFO    at org.apache.thrift.transport.TTransport.readAll(TTransport.java:86)
> 26 22:32:44,931 INFO    at org.apache.thrift.protocol.TBinaryProtocol.readAll(TBinaryProtocol.java:314)
> 26 22:32:44,931 INFO    at org.apache.thrift.protocol.TBinaryProtocol.readI32(TBinaryProtocol.java:262)
> 26 22:32:44,931 INFO    at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:192)
> 26 22:32:44,931 INFO    at fm.last.catalogue.api.TCatalogueAPI$Client.recv_getTrackById(TCatalogueAPI.java:249)
> It would be better if the client got the actual TException sent by the server, or at the very least a better error message indicating that an unexpected error occurred on the server (akin to an HTTP 500 message that most web servers use).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.