Skip to content
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

fix(email-inbound-connector): implement a reconnect and reopen mechanism #3506

Merged

Conversation

mathias-vandaele
Copy link
Contributor

@mathias-vandaele mathias-vandaele commented Oct 16, 2024

Description

As asked by @sbuettner this PR implements a re connect / re open mechanism

Related issues

closes #

Checklist

  • PR has a milestone or the no milestone label.

@mathias-vandaele mathias-vandaele requested a review from a team as a code owner October 16, 2024 15:25
@mathias-vandaele mathias-vandaele self-assigned this Oct 17, 2024
@github-actions github-actions bot temporarily deployed to connectors-email-inbound-c-c8sm October 22, 2024 09:51 Destroyed
@github-actions github-actions bot temporarily deployed to connectors-email-inbound-c-c8sm October 22, 2024 10:21 Destroyed
@mathias-vandaele mathias-vandaele force-pushed the email-inbound-connector-add-reconnection-mechanism branch from b0c267a to 7bc2c81 Compare October 22, 2024 10:23
@github-actions github-actions bot temporarily deployed to connectors-email-inbound-c-c8sm October 22, 2024 10:23 Destroyed
@github-actions github-actions bot temporarily deployed to connectors-email-inbound-c-c8sm October 22, 2024 12:02 Destroyed
@github-actions github-actions bot temporarily deployed to connectors-email-inbound-c-c8sm October 23, 2024 14:51 Destroyed
@johnBgood johnBgood modified the milestones: 8.7.0-alpha1, 8.6.3 Oct 24, 2024
try {
this.jakartaUtils.connectStore(store, authentication);
} catch (MessagingException e) {
throw new RuntimeException("Could not reconnect to store");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the exception to the log so we can find out what failed?

try {
this.folder.open(Folder.READ_WRITE);
} catch (MessagingException e) {
throw new RuntimeException("Could not reopen folder");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

@@ -130,7 +130,7 @@ private MoveEmailResponse imapMoveEmails(
sourceImapFolder.open(Folder.READ_WRITE);
Folder targetImapFolder =
store.getFolder(
String.join(String.valueOf(rootFolder.getSeparator()), toFolder.split("\\.")));
String.join(String.valueOf(rootFolder.getSeparator()), toFolder.split("[./]")));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use a constant for this.

@@ -321,7 +321,7 @@ public void moveMessage(Store store, Message message, String targetFolder) {
char separator = imapFolder.getSeparator();
String targetFolderFormatted =
Optional.ofNullable(targetFolder)
.map(string -> string.split("\\."))
.map(string -> string.split("[./]"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... and use this constant here as well?

Or create a simple static method for this logic. Would be even better

@@ -321,7 +321,7 @@ public void moveMessage(Store store, Message message, String targetFolder) {
char separator = imapFolder.getSeparator();
String targetFolderFormatted =
Optional.ofNullable(targetFolder)
.map(string -> string.split("\\."))
.map(string -> string.split("[./]"))
.map(strings -> String.join(String.valueOf(separator), strings))
.orElse("temp");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we dont need this fallback.

@github-actions github-actions bot temporarily deployed to connectors-email-inbound-c-c8sm October 24, 2024 15:11 Destroyed
.map(strings -> String.join(String.valueOf(separator), strings))
.orElse("temp");
.orElseThrow(() -> new RuntimeException("No folder has been set"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.orElseThrow(() -> new RuntimeException("No folder has been set"));
.orElseThrow(() -> new RuntimeException("No target folder has been set"));

Copy link
Collaborator

@johnBgood johnBgood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

@mathias-vandaele mathias-vandaele added this pull request to the merge queue Oct 25, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 25, 2024
@mathias-vandaele mathias-vandaele added this pull request to the merge queue Oct 25, 2024
Merged via the queue into main with commit be06a0e Oct 25, 2024
11 checks passed
@mathias-vandaele mathias-vandaele deleted the email-inbound-connector-add-reconnection-mechanism branch October 25, 2024 14:58
@sbuettner
Copy link
Contributor

Backport failed for release/8.6, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release/8.6
git worktree add -d .worktree/backport-3506-to-release/8.6 origin/release/8.6
cd .worktree/backport-3506-to-release/8.6
git switch --create backport-3506-to-release/8.6
git cherry-pick -x be06a0ee548f5049437bf24b54b2e730cdf1c582

mathias-vandaele added a commit that referenced this pull request Oct 28, 2024
…ism (#3506)

* fix(email-inbound-connector): implement a reconnect and reopen mechanism

* fix(email-connectors): add equalsIgnoreCase for INBOX

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests 2
mathias-vandaele added a commit that referenced this pull request Oct 28, 2024
…ism (#3506)

* fix(email-inbound-connector): implement a reconnect and reopen mechanism

* fix(email-connectors): add equalsIgnoreCase for INBOX

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests 2
@mathias-vandaele
Copy link
Contributor Author

/backport

@sbuettner
Copy link
Contributor

Backport failed for release/8.6, because it was unable to cherry-pick the commit(s).

Please cherry-pick the changes locally and resolve any conflicts.

git fetch origin release/8.6
git worktree add -d .worktree/backport-3506-to-release/8.6 origin/release/8.6
cd .worktree/backport-3506-to-release/8.6
git switch --create backport-3506-to-release/8.6
git cherry-pick -x be06a0ee548f5049437bf24b54b2e730cdf1c582

mathias-vandaele added a commit that referenced this pull request Oct 28, 2024
…ism (#3506)

* fix(email-inbound-connector): implement a reconnect and reopen mechanism

* fix(email-connectors): add equalsIgnoreCase for INBOX

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests 2

(cherry picked from commit be06a0e)
mathias-vandaele added a commit that referenced this pull request Oct 29, 2024
…ism (#3506)

* fix(email-inbound-connector): implement a reconnect and reopen mechanism

* fix(email-connectors): add equalsIgnoreCase for INBOX

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests 2

(cherry picked from commit be06a0e)
mathias-vandaele added a commit that referenced this pull request Nov 8, 2024
…ism (#3506)

* fix(email-inbound-connector): implement a reconnect and reopen mechanism

* fix(email-connectors): add equalsIgnoreCase for INBOX

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests

* fix(email-inbound-connector): add integration tests, modify the split for folder creation, and add unit tests 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants