Skip to content

[ISSUE #3830] InterruptedExceptions should not be ignored in the code. #4791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ public SendResult send(CloudEvent cloudEvent) {
messageId = sendResultRmq.getMsgId();
sendResult.setMessageId(messageId);
return sendResult;
} catch (InterruptedException e) {
log.error("Send message InterruptedException", e);
Thread.currentThread().interrupt(); // Restore interrupted status
return new SendResult();
} catch (Exception e) {
log.error(String.format("Send message Exception, %s", msg), e);
throw this.checkProducerException(msg.getTopic(), messageId, e);
Expand All @@ -94,6 +98,9 @@ public void sendOneway(CloudEvent cloudEvent) {
supplySysProp(msg, cloudEvent);
try {
this.rocketmqProducer.sendOneway(msg);
} catch (InterruptedException e) {
log.error("Send message oneway InterruptedException", e);
Thread.currentThread().interrupt(); // Restore interrupted status
} catch (Exception e) {
log.error(String.format("Send message oneway Exception, %s", msg), e);
throw this.checkProducerException(msg.getTopic(), MessageClientIDSetter.getUniqID(msg), e);
Expand All @@ -104,9 +111,12 @@ public void sendAsync(CloudEvent cloudEvent, SendCallback sendCallback) {
this.checkProducerServiceState(this.rocketmqProducer.getDefaultMQProducerImpl());
org.apache.rocketmq.common.message.Message msg =
RocketMQMessageFactory.createWriter(Objects.requireNonNull(cloudEvent.getSubject())).writeBinary(cloudEvent);
msg = supplySysProp(msg, cloudEvent);
supplySysProp(msg, cloudEvent);
try {
this.rocketmqProducer.send(msg, this.sendCallbackConvert(msg, sendCallback));
} catch (InterruptedException e) {
log.error("Send message async InterruptedException", e);
Thread.currentThread().interrupt(); // Restore interrupted status
} catch (Exception e) {
log.error(String.format("Send message async Exception, %s", msg), e);
throw this.checkProducerException(msg.getTopic(), MessageClientIDSetter.getUniqID(msg), e);
Expand Down Expand Up @@ -134,6 +144,9 @@ public void reply(final CloudEvent cloudEvent, final SendCallback sendCallback)

try {
this.rocketmqProducer.send(msg, this.sendCallbackConvert(msg, sendCallback));
} catch (InterruptedException e) {
log.error("Send message async InterruptedException", e);
Thread.currentThread().interrupt(); // Restore interrupted status
} catch (Exception e) {
log.error(String.format("Send message async Exception, %s", msg), e);
throw this.checkProducerException(msg.getTopic(), MessageClientIDSetter.getUniqID(msg), e);
Expand Down
Loading