Skip to content

Commit 6dd2b6e

Browse files
bug(email-connector): fix for inbound email connector when an email cant be moved 3
1 parent 8bd7efc commit 6dd2b6e

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

connectors/email/src/main/java/io/camunda/connector/email/client/jakarta/inbound/PollingManager.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package io.camunda.connector.email.client.jakarta.inbound;
88

9+
import io.camunda.connector.api.error.ConnectorException;
910
import io.camunda.connector.api.error.ConnectorRetryException;
1011
import io.camunda.connector.api.inbound.*;
1112
import io.camunda.connector.email.authentication.Authentication;
@@ -120,7 +121,9 @@ private void pollAllAndProcess(PollAll pollAll) {
120121
Message[] messages = this.folder.getMessages();
121122
Arrays.stream(messages).forEach(message -> this.processMail((IMAPMessage) message, pollAll));
122123
} catch (Exception e) {
123-
manageException(e);
124+
this.connectorContext.log(
125+
Activity.level(Severity.ERROR).tag("mail-polling").message(e.getMessage()));
126+
this.connectorContext.cancel(new ConnectorException(e.getMessage(), e));
124127
}
125128
}
126129

@@ -131,20 +134,20 @@ private void pollUnseenAndProcess(PollUnseen pollUnseen) {
131134
Arrays.stream(unseenMessages)
132135
.forEach(message -> this.processMail((IMAPMessage) message, pollUnseen));
133136
} catch (Exception e) {
134-
manageException(e);
137+
this.connectorContext.log(
138+
Activity.level(Severity.ERROR).tag("mail-polling").message(e.getMessage()));
139+
this.connectorContext.cancel(
140+
ConnectorRetryException.builder()
141+
.cause(e)
142+
.message(e.getMessage())
143+
.retries(2)
144+
.backoffDuration(Duration.of(3, ChronoUnit.SECONDS))
145+
.build());
135146
}
136147
}
137148

138149
private void manageException(Exception e) {
139-
this.connectorContext.log(
140-
Activity.level(Severity.ERROR).tag("mail-polling").message(e.getMessage()));
141-
this.connectorContext.cancel(
142-
ConnectorRetryException.builder()
143-
.cause(e)
144-
.message(e.getMessage())
145-
.retries(2)
146-
.backoffDuration(Duration.of(3, ChronoUnit.SECONDS))
147-
.build());
150+
148151
}
149152

150153
private void processMail(IMAPMessage message, PollingConfig pollingConfig) {

connectors/email/src/main/java/io/camunda/connector/email/client/jakarta/utils/JakartaUtils.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ private void processBodyPart(
284284
throws MessagingException, IOException {
285285
BodyPart bodyPart = multipart.getBodyPart(i);
286286
switch (bodyPart.getContent()) {
287-
case InputStream attachment
288-
when Part.ATTACHMENT.equalsIgnoreCase(bodyPart.getDisposition()) ->
287+
case InputStream attachment when Part.ATTACHMENT.equalsIgnoreCase(
288+
bodyPart.getDisposition()) ->
289289
emailBodyBuilder.addAttachment(
290290
new EmailAttachment(
291291
attachment,

0 commit comments

Comments
 (0)