You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2022/04/19 08:31:30 UTC

[plc4x] branch develop updated: fix(plc4j/spi): Open too many files after complete (#351)

This is an automated email from the ASF dual-hosted git repository.

cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git


The following commit(s) were added to refs/heads/develop by this push:
     new 4b151e30a6 fix(plc4j/spi): Open too many files after complete (#351)
4b151e30a6 is described below

commit 4b151e30a6ed704399b68777af0a3b02247fb734
Author: Dustone-JavaWeb <35...@users.noreply.github.com>
AuthorDate: Tue Apr 19 16:31:25 2022 +0800

    fix(plc4j/spi): Open too many files after complete (#351)
    
    Shutdown the workergroup.  remove the final tag
---
 .../org/apache/plc4x/java/spi/connection/NettyChannelFactory.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/NettyChannelFactory.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/NettyChannelFactory.java
index cd414599ca..7bdfaed2b7 100644
--- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/NettyChannelFactory.java
+++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/NettyChannelFactory.java
@@ -95,7 +95,7 @@ public abstract class NettyChannelFactory implements ChannelFactory {
         try {
             Bootstrap bootstrap = createBootstrap();
 
-            final EventLoopGroup workerGroup = getEventLoopGroup();
+            EventLoopGroup workerGroup = getEventLoopGroup();
             if (workerGroup != null) {
                 bootstrap.group(workerGroup);
             }
@@ -117,6 +117,9 @@ public abstract class NettyChannelFactory implements ChannelFactory {
             });
 
             final Channel channel = f.channel();
+            
+            // Shutdowm the workerGroup when channel closing to avoid open too many files
+            channel.closeFuture().addListener(future -> workerGroup.shutdownGracefully());
 
             // Add to event-loop group
             if (workerGroup != null) {