Skip to content

Commit

Permalink
[Fix] Handle interrupt correctly and check for lock in SmtpMailer
Browse files Browse the repository at this point in the history
  • Loading branch information
eitch committed Oct 21, 2024
1 parent a464f48 commit 3aa46a8
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion strolch-utils/src/main/java/li/strolch/utils/SmtpMailer.java
Original file line number Diff line number Diff line change
Expand Up @@ -462,11 +462,13 @@ protected String signAndEncrypt(String plainText) {

return signatureResult.toString(UTF_8);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalStateException("Interrupted while waiting to lock", e);
} catch (Exception e) {
throw new IllegalStateException("Failed to encrypt and sign plain text!", e);
} finally {
this.lock.unlock();
if (this.lock.isHeldByCurrentThread() && this.lock.isLocked())
this.lock.unlock();
}
}

Expand Down

0 comments on commit 3aa46a8

Please sign in to comment.