users@jax-rs-spec.java.net

[jax-rs-spec users] Re: Server Sent Events

From: <vrolijken_at_yahoo.com>
Date: Thu, 9 Mar 2017 11:02:21 +0100

Thanks Ondrej, I think our posts have crossed each other.

I think it’s because of my settings; I turn on nearly every warning in Eclipse. The warning I get when returning from the method is: “Potential resource leak” (Properties > Java Compiler > Errors/Warnings > Potential programming problems). I can turn it off by using @SuppressWarnings("resource"). So I guess you should ignore that.

Groeten,

Friso

Van: Ondrej Mihályi
Verzonden: donderdag 9 maart 2017 09:30
Aan: users_at_jax-rs-spec.java.net
Onderwerp: [jax-rs-spec users] Re: Server Sent Events

Hi Pavel, I think that Friso's "process" is an abstraction of an external process, which later calls another REST request, which obviously can be fulfilled in a separate thread from the initial request that initiated SSE.

I also think that the Friso's code should work. The only thing that raises my eyebrow is why would map.put(key, eventSink) create a warning on a yet unclosed eventSink. 
Is that really true, Friso? Can you share the warning you get? I believe it should be OK to store an open eventSink in a map and retrieve it by another thread, I see no reason for a warning.

Ondrej

2017-03-09 8:20 GMT+01:00 Pavel Bucek <pavel.bucek_at_oracle.com>:
Hi Friso,
the example in JAX-RS and your case is the same.
We are using executor service to show that it IS possible to send/store SseEventSink instances and work with them from another Thread.
Having said that, your case is ok and will work as it does now. The only thing is (and I believe that is just a "typo" on your side) is that it must be different Thread, not a Process, as is mentioned in the code snippet you've presented.
Best regards,
Pavel

On 09/03/2017 00:24, vrolijken_at_yahoo.com wrote:
Hi Pavel,
 
Does this clear things up? https://gist.github.com/vrolijken/a342094ea72c51ff82339504c7e1321c
 
Groeten,

Friso