Re: Question on CompletionStage


I think it make sense to file this as an issue for JAX-RS 2.2 / 3.0, so a future specification will align CXF and Jersey and give application developers safety how things shall work.


From: [] On Behalf Of Pavel Bucek
Sent: Dienstag, 22. August 2017 18:29
Subject: Re: [jaxrs] Question on CompletionStage


Hi Sergey,

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

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 :)

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.