Skip to content

Commit

Permalink
Fix IllegalReferenceCountException exception to break the callback (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
mattisonchao authored and Technoboy- committed Jul 27, 2023
1 parent 91086d3 commit 99c0414
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public AdapterChannel(MQTTProxyAdapter adapter,

public CompletableFuture<Void> writeAndFlush(final MqttAdapterMessage adapterMsg) {
checkArgument(StringUtils.isNotBlank(adapterMsg.getClientId()), "clientId is blank");
final String clientId = adapterMsg.getClientId();
adapterMsg.setEncodeType(MqttAdapterMessage.EncodeType.ADAPTER_MESSAGE);
CompletableFuture<Void> future = channelFuture.thenCompose(channel -> {
if (!channel.isActive()) {
Expand All @@ -49,7 +50,8 @@ public CompletableFuture<Void> writeAndFlush(final MqttAdapterMessage adapterMsg
return FutureUtils.completableFuture(channel.writeAndFlush(adapterMsg));
});
future.exceptionally(ex -> {
log.error("[AdapterChannel] Proxy write to broker {} message {} failed.", broker, adapterMsg, ex);
log.warn("[AdapterChannel][{}] Proxy write to broker {} failed."
+ " error message: {}", clientId, broker, ex.getMessage());
return null;
});
return future;
Expand Down

0 comments on commit 99c0414

Please sign in to comment.