users@grizzly.java.net

Re: About CompletionHandler of Grizzly2.0

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Fri, 22 May 2009 14:21:27 +0200

Fixed,
https://grizzly.dev.java.net/issues/show_bug.cgi?id=617

thank you for the patch!

WBR,
Alexey.

On May 22, 2009, at 5:31 , wenwu wrote:

>
> Hello!
>
> Now I'm using Grizzly2.0.
> A class implement org.glassfish.grizzly.CompletionHandler is as
> follow:
>
> public class CompletionHandler_WW_ClientTest implements
> CompletionHandler {
> public CompletionHandler_WW_ClientTest() {
> }
>
>
> public void cancelled(Connection connection) {
> System.out.println("cancelled");
> }
>
> public void completed(Connection connection, Object result) {
> StreamReader reader = null;
>
> reader = connection.getStreamReader();
>
> try {
> GIOPMessage rcvMessage =
> GIOPClient_WW.readerGIOPMessage(reader);
> System.out.println("rcvMessage: " +
> new String(rcvMessage.getBody()));
> } catch (Exception e) {}
> //System.out.println("completed");
> }
>
> public void failed(Connection connection, Throwable throwable) {
> System.out.println("failed");
> }
>
> public void updated(Connection connection, Object result) {
> System.out.println("updated");
> }
> }
>
> the below errors is reported when running the program:
> java.lang.NullPointerException
> at
> org
> .glassfish
> .grizzly
> .samples
> .filterchain
> .CompletionHandler_WW_ClientTest
> .completed(CompletionHandler_WW_ClientTest.java:44)
> at
> org
> .glassfish
> .grizzly
> .streams
> .AbstractStreamReader.notifySuccess(AbstractStreamReader.java:569)
> at
> org
> .glassfish
> .grizzly
> .streams
> .AbstractStreamReader.notifyCondition(AbstractStreamReader.java:209)
> at
> org
> .glassfish
> .grizzly
> .streams.AbstractStreamReader.appendBuffer(AbstractStreamReader.java:
> 198)
> at
> org.glassfish.grizzly.nio.transport.TCPNIOStreamReader
> $1.intercept(TCPNIOStreamReader.java:126)
> at
> org
> .glassfish
> .grizzly
> .nio
> .AbstractNIOAsyncQueueReader
> .intercept(AbstractNIOAsyncQueueReader.java:484)
> at
> org
> .glassfish
> .grizzly
> .nio
> .AbstractNIOAsyncQueueReader.read(AbstractNIOAsyncQueueReader.java:
> 144)
> at
> org
> .glassfish
> .grizzly
> .nio
> .transport
> .TCPNIOStreamReader
> .notifyConditionNonBlocking(TCPNIOStreamReader.java:112)
> at
> org
> .glassfish
> .grizzly
> .nio
> .transport
> .TCPNIOStreamReader.notifyCondition(TCPNIOStreamReader.java:95)
> at
> org
> .glassfish
> .grizzly
> .streams
> .AbstractStreamReader.notifyAvailable(AbstractStreamReader.java:552)
> at
> org
> .glassfish
> .grizzly
> .samples.filterchain.GIOPClient_WW.sendMsg(GIOPClient_WW.java:173)
> at
> org.glassfish.grizzly.samples.filterchain.GIOPClient_WW
> $1.run(GIOPClient_WW.java:122)
>
>
> As concerning the function completed, the param is connection always
> null!
>
> So I debug the programm. The following points will account for the
> above
> phenomeon:
> 1. in class org.glassfish.grizzly.streams.AbstractStreamReader,
>
> "completionHandler.completed(null, size); " appear in the function
> private void notifySuccess(FutureImpl<Integer> future,
> CompletionHandler<Integer> completionHandler, int size)
>
> "completionHandler.failed(null, e); " appear in the function
> private void notifyFailure(FutureImpl<Integer> future,
> CompletionHandler<Integer> completionHandler, Throwable e)
>
> so I use "this.getConnection()" instead of "null" in the above two
> functions, that is as follow:
>
> "completionHandler.completed(this.getConnection(), size); " appear
> in the
> function
> private void notifySuccess(FutureImpl<Integer> future,
> CompletionHandler<Integer> completionHandler, int size)
>
> "completionHandler.failed(this.getConnection(), e); " appear in the
> function
> private void notifyFailure(FutureImpl<Integer> future,
> CompletionHandler<Integer> completionHandler, Throwable e)
>
>
> 2. in class org.glassfish.grizzly.nio.transport.TCPNIOStreamReader,
>
> "completionHandler.failed(null, exception);",
> "completionHandler.completed(null, availableDataSize);"
> appear in the function
> public Future<Integer> notifyCondition(Condition<StreamReader>
> condition,
> CompletionHandler<Integer> completionHandler)
>
> so I use "this.getConnection()" instead of "null" in the above two
> functions, that is as follow:
>
> "completionHandler.failed(this.getConnection(), exception);",
> "completionHandler.completed(this.getConnection(),
> availableDataSize);"
> appear in the function
> public Future<Integer> notifyCondition(Condition<StreamReader>
> condition,
> CompletionHandler<Integer> completionHandler)
>
> After the alteration is taken effect, the program runs normally.
>
> Hence, the above alteration is also my advice for changing grizzly2.0.
>
> Everybody's rapid reply will be appreciated!
> --
> View this message in context: http://www.nabble.com/About-CompletionHandler-of-Grizzly2.0-tp23663880p23663880.html
> Sent from the Grizzly - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>