Skip to content

Commit

Permalink
Fix NoClassDefFoundError when opening notifications (#7556)
Browse files Browse the repository at this point in the history
Fix NoClassDefFoundError when opening notifications

* Update Changelog
* Fix similar error that can be caused by an invalid custom mailer class
* Fix Sonarcloud issues
  • Loading branch information
HoussemNasri authored Sep 30, 2023
1 parent a2f80c7 commit 0894077
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ private static void configureMailer() {
Class<? extends Mail> cobj = Class.forName(clazz).asSubclass(Mail.class);
mailer = cobj.getDeclaredConstructor().newInstance();
}
catch (Exception e) {
catch (Exception | LinkageError 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 (Exception | LinkageError e) {
getLogger().error("An exception was thrown while initializing custom mailer class", e);
return new SmtpMail();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Fix server error when visiting the notifications page

0 comments on commit 0894077

Please sign in to comment.