Skip to content

Commit

Permalink
Fix similar error that can be caused by an invalid custom mailer class
Browse files Browse the repository at this point in the history
  • Loading branch information
HoussemNasri committed Sep 19, 2023
1 parent d0ccdb6 commit 86ac473
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private static void configureMailer() {
mailer = cobj.getDeclaredConstructor().newInstance();
}
catch (Throwable e) {
log.warn("An exception was thrown while configuring Mailer", e);
log.error("An exception was thrown while initializing custom mailer class", e);
mailer = new SmtpMail();
}
}
Expand Down
10 changes: 5 additions & 5 deletions java/code/src/com/redhat/rhn/frontend/events/BaseMailAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ public void execute(EventMessage msg) {
* @return the mailer associated with this class
*/
protected Mail getMail() {
String clazz = Config.get().getString(
"web.mailer_class");
String clazz = Config.get().getString("web.mailer_class");
if (clazz == null) {
return new SmtpMail();
}
try {
Class cobj = Class.forName(clazz);
return (Mail) cobj.newInstance();
Class<? extends Mail> cobj = Class.forName(clazz).asSubclass(Mail.class);
return cobj.getDeclaredConstructor().newInstance();
}
catch (Exception e) {
catch (Throwable e) {
getLogger().error("An exception was thrown while initializing custom mailer class", e);
return new SmtpMail();
}
}
Expand Down

0 comments on commit 86ac473

Please sign in to comment.