Skip to content

Commit 86ac473

Browse files
committed
Fix similar error that can be caused by an invalid custom mailer class
1 parent d0ccdb6 commit 86ac473

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

java/code/src/com/redhat/rhn/domain/notification/UserNotificationFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ private static void configureMailer() {
7878
mailer = cobj.getDeclaredConstructor().newInstance();
7979
}
8080
catch (Throwable e) {
81-
log.warn("An exception was thrown while configuring Mailer", e);
81+
log.error("An exception was thrown while initializing custom mailer class", e);
8282
mailer = new SmtpMail();
8383
}
8484
}

java/code/src/com/redhat/rhn/frontend/events/BaseMailAction.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,16 @@ public void execute(EventMessage msg) {
5252
* @return the mailer associated with this class
5353
*/
5454
protected Mail getMail() {
55-
String clazz = Config.get().getString(
56-
"web.mailer_class");
55+
String clazz = Config.get().getString("web.mailer_class");
5756
if (clazz == null) {
5857
return new SmtpMail();
5958
}
6059
try {
61-
Class cobj = Class.forName(clazz);
62-
return (Mail) cobj.newInstance();
60+
Class<? extends Mail> cobj = Class.forName(clazz).asSubclass(Mail.class);
61+
return cobj.getDeclaredConstructor().newInstance();
6362
}
64-
catch (Exception e) {
63+
catch (Throwable e) {
64+
getLogger().error("An exception was thrown while initializing custom mailer class", e);
6565
return new SmtpMail();
6666
}
6767
}

0 commit comments

Comments
 (0)