This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new dcbd08adb4 fix(mqtt): make bootstrap server shutdown deterministic
(#7064)
dcbd08adb4 is described below
commit dcbd08adb47010b10ccbd09c4cb07394e2b4dc43
Author: Liming Deng <[email protected]>
AuthorDate: Tue Sep 15 13:25:04 2026 +0800
fix(mqtt): make bootstrap server shutdown deterministic (#7064)
---
.../docker-compose.yml | 2 ++
.../apache/shenyu/protocol/mqtt/MqttBootstrapServer.java | 16 +++++++++++-----
2 files changed, 13 insertions(+), 5 deletions(-)
diff --git
a/shenyu-integrated-test/shenyu-integrated-test-sdk-apache-dubbo/docker-compose.yml
b/shenyu-integrated-test/shenyu-integrated-test-sdk-apache-dubbo/docker-compose.yml
index 06fdf9269b..cf89d3455d 100644
---
a/shenyu-integrated-test/shenyu-integrated-test-sdk-apache-dubbo/docker-compose.yml
+++
b/shenyu-integrated-test/shenyu-integrated-test-sdk-apache-dubbo/docker-compose.yml
@@ -49,6 +49,7 @@ services:
memory: 2048M
container_name: shenyu-examples-sdk-apache-dubbo-provider
image: shenyu-examples-sdk-apache-dubbo-provider:latest
+ pull_policy: never
restart: always
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://localhost:8011/actuator/health
| grep UP || exit 1"]
@@ -71,6 +72,7 @@ services:
memory: 2048M
container_name: shenyu-examples-sdk-apache-dubbo-consumer
image: shenyu-examples-sdk-apache-dubbo-consumer:latest
+ pull_policy: never
restart: always
healthcheck:
test: ["CMD-SHELL", "wget -q -O - http://localhost:8899/actuator/health
| grep UP || exit 1"]
diff --git
a/shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/MqttBootstrapServer.java
b/shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/MqttBootstrapServer.java
index fa7fe7c0f0..3e21c24a20 100644
---
a/shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/MqttBootstrapServer.java
+++
b/shenyu-protocol/shenyu-protocol-mqtt/src/main/java/org/apache/shenyu/protocol/mqtt/MqttBootstrapServer.java
@@ -23,12 +23,12 @@ import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.util.ResourceLeakDetector;
+import java.util.Locale;
+import java.util.Objects;
import org.apache.shenyu.common.utils.Singleton;
import org.apache.shenyu.protocol.mqtt.repositories.BaseRepository;
import org.reflections.Reflections;
-import java.util.Locale;
-
/**
* mqtt server.
*/
@@ -73,9 +73,15 @@ public class MqttBootstrapServer implements BootstrapServer {
@Override
public void shutdown() {
- bossGroup.shutdownGracefully();
- workerGroup.shutdownGracefully();
- future.channel().close();
+ if (Objects.nonNull(future)) {
+ future.channel().close().syncUninterruptibly();
+ }
+ if (Objects.nonNull(bossGroup)) {
+ bossGroup.shutdownGracefully().syncUninterruptibly();
+ }
+ if (Objects.nonNull(workerGroup)) {
+ workerGroup.shutdownGracefully().syncUninterruptibly();
+ }
}
private void initRepositories() throws IllegalAccessException,
InstantiationException {