Author: markt Date: Sun Jan 16 15:41:15 2011 New Revision: 1059587 URL: http://svn.apache.org/viewvc?rev=1059587&view=rev Log: Avoid NPEs Remove FindBugs warning
Modified: tomcat/trunk/java/org/apache/naming/factory/SendMailFactory.java tomcat/trunk/res/findbugs/filter-false-positives.xml Modified: tomcat/trunk/java/org/apache/naming/factory/SendMailFactory.java URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/naming/factory/SendMailFactory.java?rev=1059587&r1=1059586&r2=1059587&view=diff ============================================================================== --- tomcat/trunk/java/org/apache/naming/factory/SendMailFactory.java (original) +++ tomcat/trunk/java/org/apache/naming/factory/SendMailFactory.java Sun Jan 16 15:41:15 2011 @@ -111,10 +111,16 @@ public class SendMailFactory implements 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; } Modified: tomcat/trunk/res/findbugs/filter-false-positives.xml URL: http://svn.apache.org/viewvc/tomcat/trunk/res/findbugs/filter-false-positives.xml?rev=1059587&r1=1059586&r2=1059587&view=diff ============================================================================== --- tomcat/trunk/res/findbugs/filter-false-positives.xml (original) +++ tomcat/trunk/res/findbugs/filter-false-positives.xml Sun Jan 16 15:41:15 2011 @@ -49,6 +49,13 @@ <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" /> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org