avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From harry wang <cool...@gmail.com>
Subject Re: NettyServer initialization
Date Wed, 14 Jul 2010 07:27:54 GMT
You are right. It looks there is no reason to let NettyServer extend from
Thread class. :)

- why

On Wed, Jul 14, 2010 at 5:57 AM, Patrick Linehan <plinehan@plinehan.com>wrote:

> I'm having a bit of trouble using NettyServer (using Avro 1.3.3 plus the
> "AVRO-405-coolwhy-new" patch).  The server's socket isn't bound in the
> constructor, it is bound in a thread started by the constructor, which
> means there is a delay before methods like "getPort" can be used.
>
> Here's a snippet that exhibits the problem:
>
> public static void main(String[] args) {
>  Server server = new NettyServer(
>    new SpecificResponder(
>      Mail.class,
>      new MailImpl()),
>    new InetSocketAddress(0));
>  while (true) {
>    try {
>      server.getPort();
>    } catch (NullPointerException e) {
>      System.err.println("npe");
>      continue;
>    }
>    break;
>  }
>  System.err.println("done");
> }
>
> The above code prints "npe" a number of times before finally
> printing "done".  There is no way to detect, AFAICT, when the server is
> ready to start using.  My current hack is to just sleep for a few seconds
> after construction.
>
> Is there any reason the setup is done in a different thread?  Would
> you accept a patch to instead perform the initialization in the
> constructor?
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message