MimeMessage message = new MimeMessage(
Session.getInstance(props));
try {
- String from = (String)ref.get("mail.from").getContent();
- message.setFrom(new InternetAddress(from));
+ RefAddr fromAddr = ref.get("mail.from");
+ String from = null;
+ if (fromAddr != null) {
+ from = (String)ref.get("mail.from").getContent();
+ }
+ if (from != null) {
+ message.setFrom(new InternetAddress(from));
+ }
message.setSubject("");
- } catch (Exception e) {}
+ } catch (Exception e) {/*Ignore*/}
MimePartDataSource mds = new MimePartDataSource(message);
return mds;
}
<Bug code="NS"/>
</Match>
<Match>
+ <!-- Simpler to catch Exception than to create dummy implementations of the
+ necessary exception hierarchy -->
+ <Class name="org.apache.naming.factory.SendMailFactory$1" />
+ <Method name="run" />
+ <Bug code="DE" />
+ </Match>
+ <Match>
<!-- Class name needs to start with a lower case letter in this case -->
<Class name="org.apache.naming.java.javaURLContextFactory" />
<Bug code="Nm" />