You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ta...@apache.org on 2023/06/20 22:01:41 UTC
[qpid-protonj2] branch main updated: PROTON-2744 Ensure the test peer client shuts down its event loop
This is an automated email from the ASF dual-hosted git repository.
tabish pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/qpid-protonj2.git
The following commit(s) were added to refs/heads/main by this push:
new a35e8ccc PROTON-2744 Ensure the test peer client shuts down its event loop
a35e8ccc is described below
commit a35e8cccdaed41a2cd0efb296f58990741d71d77
Author: Timothy Bish <ta...@gmail.com>
AuthorDate: Tue Jun 20 18:01:14 2023 -0400
PROTON-2744 Ensure the test peer client shuts down its event loop
The event loops created for the client in the test peer should be closed
immediately on channel close.
---
.../protonj2/test/driver/netty/netty4/Netty4Client.java | 13 +++++++++++++
.../protonj2/test/driver/netty/netty5/Netty5Client.java | 13 +++++++++++++
2 files changed, 26 insertions(+)
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/netty/netty4/Netty4Client.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/netty/netty4/Netty4Client.java
index 1db99dc2..2f2eddca 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/netty/netty4/Netty4Client.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/netty/netty4/Netty4Client.java
@@ -80,6 +80,7 @@ public final class Netty4Client implements NettyClient {
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final String AMQP_SUB_PROTOCOL = "amqp";
+ private static final int SHUTDOWN_TIMEOUT = 50;
private Netty4EventLoop eventLoop;
private Bootstrap bootstrap;
@@ -122,6 +123,18 @@ public final class Netty4Client implements NettyClient {
LOG.debug("Close of channel interrupted while awaiting result");
}
}
+
+ if (group != null && !group.isShutdown()) {
+ group.shutdownGracefully(0, SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS);
+ try {
+ if (!group.awaitTermination(2 * SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ LOG.trace("Connection IO Event Loop shutdown failed to complete in allotted time");
+ }
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ LOG.debug("Shutdown of netty event loop interrupted while awaiting result");
+ }
+ }
}
}
diff --git a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/netty/netty5/Netty5Client.java b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/netty/netty5/Netty5Client.java
index bc8a0925..a9d3e16a 100644
--- a/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/netty/netty5/Netty5Client.java
+++ b/protonj2-test-driver/src/main/java/org/apache/qpid/protonj2/test/driver/netty/netty5/Netty5Client.java
@@ -79,6 +79,7 @@ public final class Netty5Client implements NettyClient {
private static final Logger LOG = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private static final String AMQP_SUB_PROTOCOL = "amqp";
+ private static final int SHUTDOWN_TIMEOUT = 50;
private Netty5EventLoop eventLoop;
private Bootstrap bootstrap;
@@ -121,6 +122,18 @@ public final class Netty5Client implements NettyClient {
LOG.debug("Close of channel interrupted while awaiting result");
}
}
+
+ if (group != null && !group.isShutdown()) {
+ group.shutdownGracefully(0, SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS);
+ try {
+ if (!group.awaitTermination(2 * SHUTDOWN_TIMEOUT, TimeUnit.MILLISECONDS)) {
+ LOG.trace("Connection IO Event Loop shutdown failed to complete in allotted time");
+ }
+ } catch (InterruptedException e) {
+ Thread.interrupted();
+ LOG.debug("Shutdown of netty event loop interrupted while awaiting result");
+ }
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org