From: markt Date: Sun, 16 Jan 2011 15:41:15 +0000 (+0000) Subject: Avoid NPEs X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=f21f8d8d7085d783d3718bae48462cce4d40c5c8;p=tomcat7.0 Avoid NPEs Remove FindBugs warning git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1059587 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/naming/factory/SendMailFactory.java b/java/org/apache/naming/factory/SendMailFactory.java index 57e0d3571..16aeb7903 100644 --- a/java/org/apache/naming/factory/SendMailFactory.java +++ b/java/org/apache/naming/factory/SendMailFactory.java @@ -111,10 +111,16 @@ public class SendMailFactory implements ObjectFactory 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; } diff --git a/res/findbugs/filter-false-positives.xml b/res/findbugs/filter-false-positives.xml index ed135693e..27d436837 100644 --- a/res/findbugs/filter-false-positives.xml +++ b/res/findbugs/filter-false-positives.xml @@ -49,6 +49,13 @@ + + + + + +