dev@grizzly.java.net

Re: Context#write vs. Connection.write

From: Oleksiy Stashok <oleksiy.stashok_at_oracle.com>
Date: Fri, 22 Feb 2013 11:36:22 -0800

Hi Tigran,


On 22.02.13 02:22, Tigran Mkrtchyan wrote:
> Hi,
>
> I have in the code following lines:
>
> context.write(context.getAddress(), buffer, null);
>
> is it safe to replace with:
>
> connection = context.getConnection();
> remoteAddress = (InetSocketAddress)context.getAddress();
>
> connection.write(remoteAddress, buffer, null);
>
> The main difference is that point where I use connection is much later
> and executed by other thread ( e.q. I am building in async reply
> mechanism).
>
> Well, it works but I want to be sure that it's reliable.
ctx.write(...) is basically writing message starting from the *current*
(FilterChainContext) filter downstream.
connection.write(...) writes the message start from the *last* Filter in
chain downstream.

WBR,
Alexey.

>
> Thanks,
> Tigran.