Spring-cloud-netflix: SingleDeferredResult prevents TimeoutDeferredResultProcessingInterceptor from executing on timeout

Created on 14 Sep 2016  路  2Comments  路  Source: spring-cloud/spring-cloud-netflix

When returning a Single from my RestController in case of timeout I expect a 503 as specified by
TimeoutDeferredResultProcessingInterceptor instead I get a 406 and TimeoutDeferredResultProcessingInterceptor is not executed.

SingleDeferredResult uses a new object EMPTY_RESULT as timeoutObject instead of reusing RESULT_NONE from DeferedResult as a result the DeferredResultInterceptorChain is interrupted.

A simple fix would be to remove EMPTY_RESULT from SingleDeferredResult

class SingleDeferredResult<T> extends DeferredResult<T> {

    public SingleDeferredResult(Single<T> single) {
        initSingle(single);
    }

    public SingleDeferredResult(long timeout, Single<T> single) {
        super(timeout);
        initSingle(single);
    }

    public SingleDeferredResult(Long timeout, Object timeoutResult, Single<T> single) {
        super(timeout, timeoutResult);
        initSingle(single);
    }

    private void initSingle(Single<T> single) {
        Assert.notNull(single, "single can not be null");
        new DeferredResultSubscriber<>(single.toObservable(), this);
    }
}
bug help wanted

Most helpful comment

How about a PR?

All 2 comments

How about a PR?

Close via #1451

Was this page helpful?
0 / 5 - 0 ratings