avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sudharsan Sampath <sudha...@gmail.com>
Subject Re: SaslSocketServer.close() doesn't close?
Date Tue, 14 Jun 2011 05:05:05 GMT
Hi,

I tried but have the same issue. I added server.join() after the close call
instead of waiting for a pre-defined time. But it hangs indefinitely.

-Sudhan S

On Mon, Jun 13, 2011 at 10:07 PM, Alex Miller <alex@puredanger.com> wrote:

> Hello all,
>
> I've been having an issue in some tests where it appears that closing
> a SaslSocketServer does not actually cause the socket to be closed.
> The code below reproduces roughly what happens in the course of a much
> more complicated test.  Basically I start a socket server, close() it,
> then try to start another on the same port which fails to bind as the
> address is in use.
>
> From trolling through the code, it is not immediately obvious that any
> code exists to actually close the socket.  The nio thread group gets
> interrupted which from debugging into this, does seem to cause the
> Connection threads to break out of their loop and close but the main
> socket listener (which is not a member of the thread group) and the
> socket channel do not get closed.
>
> Am I crazy?
>
>
>
> import java.net.InetAddress;
> import java.net.InetSocketAddress;
>
> import org.apache.avro.Protocol;
> import org.apache.avro.Schema;
> import org.apache.avro.Protocol.Message;
> import org.apache.avro.io.Decoder;
> import org.apache.avro.io.Encoder;
> import org.apache.avro.ipc.Responder;
> import org.apache.avro.ipc.SaslSocketServer;
> import org.apache.avro.ipc.Server;
>
> public class SocketDoesntClose extends Responder {
>
>  public static void main(String[] args) throws Exception {
>
>    Protocol prot = new Protocol("c", "a.b");
>
>    // start on port 9999
>    InetSocketAddress addr = new
> InetSocketAddress(InetAddress.getLocalHost(), 9999);
>    Server server = new SaslSocketServer(new SocketDoesntClose(prot), addr);
>    server.start();
>
>    // stop -- I would expect this to fully release the socket
>    server.close();
>
>    Thread.sleep(10000);
>
>    // start on same socket again -> address already in use
>    server = new SaslSocketServer(new SocketDoesntClose(prot), addr);
>  }
>
>  // dummy implementation
>  public SocketDoesntClose(Protocol local) {
>    super(local);
>  }
>
>  public Object readRequest(Schema actual, Schema expected, Decoder in) {
>    return null;
>  }
>
>  public Object respond(Message message, Object request) {
>    return null;
>  }
>
>  public void writeError(Schema schema, Object error, Encoder out) {
>  }
>
>  public void writeResponse(Schema schema, Object response, Encoder out) {
>  }
> }
>

Mime
View raw message