Comments (3)
Hi, could you provide real stacktraces on client side and server side?
from spring-thrift-starter.
Thrift generated sources always declare a org.apache.thrift.TException
on methods:
public class TService {
public interface Iface {
public Response act() throws MyException, org.apache.thrift.TException;
...
}
}
An implementing class is usually overriding the method with declaring only a custom exception. Since it never throws a org.apache.thrift.TException
, why bother declaring it? Example:
public class ThriftEndpoint implements TService.Iface
@Override
public Response act() throws MyException {...}
In runtime, methods of the implementing class are proxied by LoggingThriftMethodInterceptor
, and should a subclass of RuntimeException
be thrown from the method, the interceptor wil wrap it into a TApplicationException
and rethrow it. Since TApplicationException
is not declared in method signature of the implementing class, it becomes an UndeclaredThrowableException
and then a TTransportException
with message HTTP Response code: 406
.
Possible workarounds:
- always declare
org.apache.thrift.TException
on methods in implementing classes, even if they are not actually thrown by the method code itself:
@Override
Response act() throws MyException, org.apache.thrift.TException {...}
This will lead to TTransportException with Internal error processing {methodName}
message, but message from the original exception will not be delivered to client, so this workaround is obviosly not ideal.
- catch any Exceptions in method and wrap them into declared custom exception (it always extends
TException
and will not be wrapped by interceptor):
@Override
Response act() throws MyException {
try {
...
} catch (Exception e) {
throw new MyException(e);
}
}
I've provided logs here: logs.zip
Also I've written some tests in my fork (https://github.com/jihor/spring-thrift-starter), see TGreetingServiceHandlerTests
class, methods are:
testMappedClientWithCustomException()
- corresponds to workaround (2);testMappedClientWithRuntimeException1()
- corresponds to workaround (1);testMappedClientWithRuntimeException2()
- this is what you get by default, anHTTP Response code: 406
;
It might be useful to merge these tests into master.
from spring-thrift-starter.
Hmm, maybe it's worth deleting any exception wrapping from LoggingThriftMethodInterceptor
. It's an interceptor for logging an it shouldn't interfere with application flow. Then, should you throw a RuntimeExcepton
from your method, you will get a TTransportException
on client regardless of the method signature.
EDIT: You will actually still get HTTP Response code: 406
, but this time it will not depend on method signature. Well, still better than getting different exception classes based on what did you define on your method.
from spring-thrift-starter.
Related Issues (14)
- Implement SpanInjector and SpanExtractor patterns HOT 1
- Migrate from @ThriftHandler to @ThriftController notation
- NullPointerException in TLoadBalancerClient HOT 1
- Add hystrix support
- Not so active the project is HOT 1
- spring-thrift-starter:1.5.0 does not exists in jcenter HOT 1
- Still maintained? HOT 2
- Could not find org.apache.thrift:thrift:0.9.2 for windows
- New client bean registration logic doesn't work
- Migrating to Spring Boot 1.3.x HOT 1
- Is socket client connection supported?
- Add timeouts for Thrift clients HOT 1
- End-to-end forwarding "x-request-id" HTTP Header HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-thrift-starter.