Hello,
I am trying to use Avro RPC for my new project but havinga problem with
shutting down the client application.The client application looks like the code
below.When the server is not executed, the client fails in the constructorof
NettyTransceiver() and the main thread finishes but worker threads created by
the thread pool for Netty remains.So the process can not terminate for long
time or forever.NetyTransceiver.close() calls
ChannelFactory.releaseExternalResources()but it is not called when the
constructor failed.Is there any solution to this problem?
Thanks in advance,Tada
<Soruce code>static void showThreads() { System.out.println("###
showThreads"); int count = Thread.activeCount();
System.out.println("### " + count + " active threads"); Thread[] th =
new Thread[count]; Thread.enumerate(th); for (int i=0; i<count;
i++) { System.out.println(i + ": " + th[i]); } }
public static void main(String[] args) { try (NettyTransceiver client = new
NettyTransceiver(new InetSocketAddress(65111))) {
System.out.println("Connected!"); } catch (IOException e) {
e.printStackTrace(); showThreads(); }}
<Execution
result>-------------------------------------------------------------------------------java.io.IOException:
Error connecting to 0.0.0.0/0.0.0.0:65111 at
org.apache.avro.ipc.NettyTransceiver.getChannel(NettyTransceiver.java:280) at
org.apache.avro.ipc.NettyTransceiver.<init>(NettyTransceiver.java:206) at
org.apache.avro.ipc.NettyTransceiver.<init>(NettyTransceiver.java:155) at
org.apache.avro.ipc.NettyTransceiver.<init>(NettyTransceiver.java:123) at
org.apache.avro.ipc.NettyTransceiver.<init>(NettyTransceiver.java:110) at
agra.mmsclient.Test.test3(Test.java:157) at
agra.mmsclient.Test.main(Test.java:30)Caused by: java.net.ConnectException:
Connection refused: 0.0.0.0/0.0.0.0:65111 at
sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) at
sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:701) at
org.jboss.netty.channel.socket.nio.NioClientBoss.connect(NioClientBoss.java:150)
at
org.jboss.netty.channel.socket.nio.NioClientBoss.processSelectedKeys(NioClientBoss.java:105)
at
org.jboss.netty.channel.socket.nio.NioClientBoss.process(NioClientBoss.java:79)
at
org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:312)
at
org.jboss.netty.channel.socket.nio.NioClientBoss.run(NioClientBoss.java:42) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)### showThreads### 11 active
threads0: Thread[main,5,main]1: Thread[New I/O worker #1,5,main]2: Thread[New
I/O worker #2,5,main]3: Thread[New I/O worker #3,5,main]4: Thread[New I/O
worker #4,5,main]5: Thread[New I/O worker #5,5,main]6: Thread[New I/O worker
#6,5,main]7: Thread[New I/O worker #7,5,main]8: Thread[New I/O worker
#8,5,main]9: Thread[New I/O boss #9,5,main]10: Thread[Hashed wheel timer
#1,5,main]-------------------------------------------------------------------------------