You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@avro.apache.org by rs...@apache.org on 2021/06/30 15:45:16 UTC
[avro] branch master updated: AVRO-3165: Fix NettyTransceiver
workerGroup leak (#1274)
This is an automated email from the ASF dual-hosted git repository.
rskraba pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new 72b3c51 AVRO-3165: Fix NettyTransceiver workerGroup leak (#1274)
72b3c51 is described below
commit 72b3c51512752f471392e3e5eaa40f954a99b752
Author: Benjamin Leber <gr...@grisu118.ch>
AuthorDate: Wed Jun 30 17:45:05 2021 +0200
AVRO-3165: Fix NettyTransceiver workerGroup leak (#1274)
---
.../src/main/java/org/apache/avro/ipc/netty/NettyTransceiver.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/lang/java/ipc-netty/src/main/java/org/apache/avro/ipc/netty/NettyTransceiver.java b/lang/java/ipc-netty/src/main/java/org/apache/avro/ipc/netty/NettyTransceiver.java
index d75254a..020d1c4 100644
--- a/lang/java/ipc-netty/src/main/java/org/apache/avro/ipc/netty/NettyTransceiver.java
+++ b/lang/java/ipc-netty/src/main/java/org/apache/avro/ipc/netty/NettyTransceiver.java
@@ -73,7 +73,7 @@ public class NettyTransceiver extends Transceiver {
private final Integer connectTimeoutMillis;
private final Bootstrap bootstrap;
private final InetSocketAddress remoteAddr;
- private final EventLoopGroup workerGroup = new NioEventLoopGroup(new NettyTransceiverThreadFactory("avro"));
+ private final EventLoopGroup workerGroup;
volatile ChannelFuture channelFuture;
volatile boolean stopping;
@@ -92,6 +92,7 @@ public class NettyTransceiver extends Transceiver {
bootstrap = null;
remoteAddr = null;
channelFuture = null;
+ workerGroup = null;
}
/**
@@ -171,6 +172,7 @@ public class NettyTransceiver extends Transceiver {
connectTimeoutMillis = DEFAULT_CONNECTION_TIMEOUT_MILLIS;
}
this.connectTimeoutMillis = connectTimeoutMillis;
+ workerGroup = new NioEventLoopGroup(new NettyTransceiverThreadFactory("avro"));
bootstrap = new Bootstrap().group(workerGroup).channel(NioSocketChannel.class)
.option(ChannelOption.SO_KEEPALIVE, true).option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connectTimeoutMillis)
.option(ChannelOption.TCP_NODELAY, DEFAULT_TCP_NODELAY_VALUE).handler(new ChannelInitializer<SocketChannel>() {
@@ -397,7 +399,9 @@ public class NettyTransceiver extends Transceiver {
disconnect(awaitCompletion, true, null);
} finally {
// Shut down all thread pools to exit.
- workerGroup.shutdownGracefully();
+ if (workerGroup != null) {
+ workerGroup.shutdownGracefully();
+ }
}
}