Author: sgoeschl Date: Tue Feb 24 22:21:25 2009 New Revision: 747581 URL: http://svn.apache.org/viewvc?rev=747581&view=rev Log: [EMAIL-71] Email.getHostName() throws NullPointerException
Modified: commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java commons/proper/email/trunk/xdocs/changes.xml Modified: commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java?rev=747581&r1=747580&r2=747581&view=diff ============================================================================== --- commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java (original) +++ commons/proper/email/trunk/src/java/org/apache/commons/mail/Email.java Tue Feb 24 22:21:25 2009 @@ -1239,10 +1239,11 @@ { return this.hostName; } - else + else if (this.session != null) { return this.session.getProperty(MAIL_HOST); } + return null; } /** @@ -1256,10 +1257,11 @@ { return this.smtpPort; } - else + else if (this.session != null) { return this.session.getProperty(MAIL_PORT); } + return null; } /** @@ -1339,10 +1341,11 @@ { return this.sslSmtpPort; } - else + else if (this.session != null) { return this.session.getProperty(MAIL_SMTP_SOCKET_FACTORY_PORT); } + return null; } /** Modified: commons/proper/email/trunk/xdocs/changes.xml URL: http://svn.apache.org/viewvc/commons/proper/email/trunk/xdocs/changes.xml?rev=747581&r1=747580&r2=747581&view=diff ============================================================================== --- commons/proper/email/trunk/xdocs/changes.xml (original) +++ commons/proper/email/trunk/xdocs/changes.xml Tue Feb 24 22:21:25 2009 @@ -24,6 +24,12 @@ <body> <release version="1.2-SNAPSHOT" date="as in SVN"> + <action dev="sgoeschl" type="fix" issue="EMAIL-71" date="2009-02-22" due-to="Teemu Lang, Corey Scott"> + If setHostName() has not been called, getHostName() tries to return + this.session.getProperty(MAIL_HOST). If mail session has not been + created yet, this will throw a NullPointerException. Now getHostName() + checks that this.session is not null before trying to access it. + </action> <action dev="sgoeschl" type="fix" issue="EMAIL-81" date="2009-02-22" due-to="Travis Reader, Corey Scott"> Add getTo and getReplyTo to Email class. </action>