Re: Question on CompletionStage

Sergey Beryozkin

Hi Pavel

On 22/08/17 17:29, Pavel Bucek wrote:

Hi Sergey,

I guess that's fine, unless someone registers MessageBodyWriter for Observable, which might then now work properly.

You are right technically having MBW<Observable> is a possibility but practically speaking I can't see anyone doing it, though this is how I started from myself, but it might only work for something like Observable.just("Hello World")

I'm not saying that because I think that it shouldn't be done, its just something which is not defined by the specification and JAX-RS user can't rely on this to work everywhere.

// and I'm certainly not saying that we won't do something like that for Jersey :)

Yeah, lets go beyond the spec limits a bit :-)

Thanks, Sergey

Thanks and regards,

On 22/08/2017 16:58, Sergey Beryozkin wrote:
Hi Pavel

FYI, in CXF returning Observable will be handled similarly to returning CompletionStage

Cheers, Sergey
On 22/08/17 09:06, Pavel Bucek wrote:

Hi Markus,

confirming what you wrote would be extending of what is pretty explicitly written in the spec, so I can't do that.

Currently, the behavior is "defined" by what AsyncResponse provides and there is nothing like you mentioned there, so I don't think that the usecase you described is supported - returned Observable (or any other type) will be processed as any other type, so the pipeline will be triggered right after the object is returned from the resource method.

Returning CompletionStage is equal to invoking AsyncResponse#resume in CompletionStage#whenComplete callback, nothing more, nothing less..


On 18/08/2017 17:23, Markus KARG wrote:



as the spec does not explicitly mention it, can you please confirm that what the spec actually wants to say is that CompletionStage does not only imply async when declared as a method's return type, but also when CompletionStage is de-facto returned by a method or by a interceptor (i. e. the method itself is not declared to return CompletionStage, but might return Object and an interceptor produces a CompletionStage from that)? This would allow framework providers to provide "JAX-RS adapter" like an interceptor turning RxJava's Observable into Java 8's CompletionStage. The spec is a bit short here.




Join to automatically receive all group messages.