<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p>Very nice!! Much better. Hats off to Professeur Fromage!!<br>
</p>
<br>
<div class="moz-cite-prefix">On 06/18/2018 10:21 AM, Stephane
Epardaud wrote:<br>
</div>
<blockquote type="cite"
cite="mid:e496515b-acd4-81b6-5f50-0e8bef68d40e@epardaud.fr">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Oh yeah, funny indeed. What sucks is that there's no plugin/hook
for automatic context propagation for CompletionStage, but yes, we
could mention in the docs you pointed to that for rxjava1/2 this
actually works and is automatic. We could also point out that if
you import the resteasy-reactive-context module, you can rewrite
the example with:<br>
@GET<br>
@Path("test")<br>
@Produces("text/plain")<br>
public CompletionStage&lt;String&gt; text(@Context
HttpRequest request) {<br>
System.out.println("request (inline): " + request);<br>
System.out.println("application (inline): " +
ResteasyProviderFactory.getContextData(Application.class));<br>
CompletableFuture&lt;String&gt; cs = new
CompletableFuture&lt;&gt;();<br>
ExecutorService executor = Executors.newSingleThreadExecutor();<br>
Object[] contexts = Context.capture();<br>
executor.submit(<br>
new Runnable() {<br>
public void run() {<br>
Object[] oldContexts = Context.install(contexts);<br>
try {<br>
System.out.println("request (async): " +
request); <br>
System.out.println("application (async): " +
ResteasyProviderFactory.getContextData(Application.class));<br>
cs.complete("hello");<br>
} catch (Exception e) {<br>
e.printStackTrace();<br>
} finally {<br>
Context.restore(oldContexts);<br>
}<br>
}<br>
});<br>
return cs;<br>
}<br>
<br>
Note that this gets you the resteasy context but also CDI and any
other reactive context provider that is in the classpath.<br>
<br>
And in fact I think I should add wrappers that do this
automatically for Runnable and CompletionStage in
reactive-contexts-core, now that I look at this.<br>
<br>
<div class="moz-cite-prefix">On 18/06/18 16:13, Alessio Soldano
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAKQecn9PWuVBsD3bxj8aot6X1Hbzi63t8=2Q4UjRr8rZ5CmFYA@mail.gmail.com">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>Hi Stephane,<br>
</div>
funnily enough, the last commit on resteasy master
is related to the issue you're mentioning: <a
href="https://github.com/resteasy/Resteasy/commit/89badabb88b4d98e7f8d06f0ae0330ca21227bfe"
moz-do-not-send="true">https://github.com/resteasy/Resteasy/commit/89badabb88b4d98e7f8d06f0ae0330ca21227bfe</a><br>
</div>
So, yes, I think a solution for this problem will
always be better than only telling users to be aware
of the problem, which is what we were going to do.<br>
</div>
17KB of dependencies for this are clearly fine.<br>
</div>
Looking forward for the PR ;-)<br>
</div>
Thanks<br>
</div>
<br>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">On Mon, Jun 18, 2018 at 3:14 PM,
Stephane Epardaud <<a href="mailto:stef@epardaud.fr"
target="_blank" moz-do-not-send="true">stef@epardaud.fr</a>>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div text="#000000" bgcolor="#FFFFFF"> <br>
Hi,<br>
<br>
At the moment, the resteasy-rxjava and resteasy-rxjava2
modules register hooks into the rxjava and rxjava2
plugin/hook system, in order to propagate the RESTEasy
context (thread-local) into all phases of rxjava
single/flowable/etc, which can otherwise be scheduled on
any scheduler/thread and so would lose the RESTEasy
context.<br>
<br>
RxJava being what it is, you can only register a single
plugin/hook globally, so if RESTEasy defines it, nobody
else can. That's problematic, because CDI also requires
context propagation, and so does Redpipe (to name just
the two examples I am using ATM), so I created a library
called Reactive Contexts which decouples libraries that
have a context to propagate (RESTEasy, CDI, Redpipe,
etc…) and libraries that provide context propagation
(RxJava1, 2, etc…).<br>
<br>
<a class="m_-7388058967013385691moz-txt-link-freetext"
href="https://reactiverse.io/reactive-contexts"
target="_blank" moz-do-not-send="true">https://reactiverse.io/<wbr>reactive-contexts</a><br>
<br>
<br>
That library is super small (4k core, 13k propagator for
rxjava). I'd like to remove the custom context
propagation in the resteasy-rxjava/rxjava2 and make
those modules depend on a new resteasy-reactive-context
which would depend on reactive-contexts-core to provide
a context provider for RESTEasy.<br>
<br>
This way, I can also make CDI and Redpipe provide such a
module and all those contexts will be propagated for
rxjava for all users :)<br>
<br>
WDYT? Do you agree on that extra dependency ? It's only
for the rxjava modules, not the core.<br>
<br>
<br>
<br>
</div>
<br>
______________________________<wbr>_________________<br>
resteasy-dev mailing list<br>
<a href="mailto:resteasy-dev@lists.jboss.org"
moz-do-not-send="true">resteasy-dev@lists.jboss.org</a><br>
<a
href="https://lists.jboss.org/mailman/listinfo/resteasy-dev"
rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.jboss.org/<wbr>mailman/listinfo/resteasy-dev</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
<div class="gmail_signature" data-smartmail="gmail_signature">
<div dir="ltr">
<div> <br>
Alessio Soldano<br>
<br>
Associate Manager<br>
<br>
<a
style="color:#0088ce;font-size:10px;margin:0;text-decoration:none;font-family:'overpass',sans-serif"
href="https://www.redhat.com" target="_blank"
moz-do-not-send="true">Red Hat <br>
<br>
</a><br>
<table border="0">
<tbody>
<tr>
<td width="100px"><a href="https://red.ht/sig"
target="_blank" moz-do-not-send="true"> <img
src="https://www.redhat.com/files/brand/email/sig-redhat.png"
moz-do-not-send="true" width="90"
height="auto"></a> </td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</blockquote>
<br>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
resteasy-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:resteasy-dev@lists.jboss.org">resteasy-dev@lists.jboss.org</a>
<a class="moz-txt-link-freetext" href="https://lists.jboss.org/mailman/listinfo/resteasy-dev">https://lists.jboss.org/mailman/listinfo/resteasy-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
My company's smarter than your company (unless you work for Red Hat)</pre>
</body>
</html>