Skip to content

Commit

Permalink
#264: switch from AssertionError to IllegalStateException (see https:…
Browse files Browse the repository at this point in the history
  • Loading branch information
bbottema committed Jul 5, 2020
1 parent 532f1fd commit 15c5af4
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public String propertyNameSSLTrust() {
*/
@Override
public String propertyNameCheckServerIdentity() {
throw new AssertionError("This property is not relevant for plain SMTP");
throw new IllegalStateException("This property is not relevant for plain SMTP");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static X509Certificate readFromPem(InputStream pemData)
Class<Provider> bouncyCastleClass = (Class<Provider>) forName(BOUNCY_CASTLE_PROVIDER_CLASS);
Security.addProvider(getProvider(bouncyCastleClass));
} catch (ClassNotFoundException e) {
throw new AssertionError(format("Class found but also not found??? (%s)", BOUNCY_CASTLE_PROVIDER_CLASS));
throw new IllegalStateException(format("Class found but also not found??? (%s)", BOUNCY_CASTLE_PROVIDER_CLASS));
}
} else {
throw new SmimeSupportMissingException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static Boolean convertToBoolean(@Nullable final Object value) {
} else if (strValue.equalsIgnoreCase("false") || strValue.equalsIgnoreCase("0")) {
return false;
}
throw new AssertionError("Wrong property must have been requested");
throw new IllegalArgumentException("Wrong property must have been requested");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ public static MimeMessage emailToMimeMessage(@NotNull final Email email, @NotNul
return MimeMessageProducerHelper.produceMimeMessage(checkNonEmptyArgument(email, "email"), checkNonEmptyArgument(session, "session"));
} catch (UnsupportedEncodingException | MessagingException e) {
// this should never happen, so we don't acknowledge this exception (and simply bubble up)
throw new AssertionError(e.getMessage(), e);
throw new IllegalStateException(e.getMessage(), e);
}
}

Expand Down Expand Up @@ -510,7 +510,7 @@ public static String mimeMessageToEML(@NotNull final MimeMessage mimeMessage) {
return os.toString(UTF_8.name());
} catch (IOException | MessagingException e) {
// this should never happen, so we don't acknowledge this exception (and simply bubble up)
throw new AssertionError("This should never happen", e);
throw new IllegalStateException("This should never happen", e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public String toString() {
try {
return "MimeMessage<id:" + super.getMessageID() + ", subject:" + super.getSubject() + ">";
} catch (MessagingException e) {
throw new AssertionError("should not reach here");
throw new IllegalStateException("should not reach here");
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ public static MimeMessage produceMimeMessage(@NotNull Email email, @NotNull Sess
return mimeMessageProducer.populateMimeMessage(email, session);
}
}
throw new AssertionError("no compatible MimeMessageProducer found for email");
throw new IllegalStateException("no compatible MimeMessageProducer found for email");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public static SMIMEModule loadSmimeModule() {

public static BatchModule loadBatchModule() {
if (FORCED_DISABLED_MODULES.contains(BatchModule.class)) {
throw new AssertionError("BatchModule forcefully disabled");
throw new IllegalStateException("BatchModule forcefully disabled");
}
if (!LOADED_MODULES.containsKey(BatchModule.class)) {
LOADED_MODULES.put(BatchModule.class, loadModule(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ public final AsyncResponse sendMail(final Email email, @SuppressWarnings("SamePa
.executeAsync(operationalConfig.getExecutorService(), "sendMail process", sendMailClosure);
}
}
throw new AssertionError("Email not valid, but no MailException was thrown for it");
throw new IllegalStateException("Email not valid, but no MailException was thrown for it");
}

/**
Expand Down

0 comments on commit 15c5af4

Please sign in to comment.