commits@javamail.java.net

[mercurial:85] SMTP I/O failure incorrectly reports valid sent addresses

From: <shannon_at_kenai.com>
Date: Tue, 11 Nov 2008 01:05:08 +0000 (GMT)

Repository: mercurial
Revision: 85
Author: Bill Shannon <bill.shannon_at_sun.com>
Date: 2008-09-19 20:43:41 UTC

Log Message:
-----------
SMTP I/O failure incorrectly reports valid sent addresses

Modified Paths:
--------------
    doc/release/CHANGES.txt
    mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java

Diffs:
-----
diff -r a1b385acafb3 -r 9a4783d20c83 doc/release/CHANGES.txt
--- a/doc/release/CHANGES.txt Fri Sep 12 14:03:36 2008 -0700
+++ b/doc/release/CHANGES.txt Fri Sep 19 13:43:41 2008 -0700
@@ -46,6 +46,7 @@
 <no id> add mail.<protocol>.ssl.enable property
 <no id> add mail.mime.parameters.strict property to control
ParameterList parse
 <no id> fix possible NPE in MimeMessage if flags is not set in
copy constructor
+<no id> SMTP I/O failure incorrectly reports valid sent
addresses
 
 
                  CHANGES IN THE 1.4.1 RELEASE
diff -r a1b385acafb3 -r 9a4783d20c83
mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java
--- a/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java Fri Sep
12 14:03:36 2008 -0700
+++ b/mail/src/main/java/com/sun/mail/smtp/SMTPTransport.java Fri Sep
19 13:43:41 2008 -0700
@@ -756,6 +756,7 @@
        } catch (MessagingException mex) {
            if (debug)
                mex.printStackTrace(out);
+ addressesFailed();
           
notifyTransportListeners(TransportEvent.MESSAGE_NOT_DELIVERED,
                                     validSentAddr, validUnsentAddr,
                                     invalidAddr, this.message);
@@ -769,6 +770,7 @@
            try {
                closeConnection();
            } catch (MessagingException mex) { /* ignore it */ }
+ addressesFailed();
           
notifyTransportListeners(TransportEvent.MESSAGE_NOT_DELIVERED,
                                     validSentAddr, validUnsentAddr,
                                     invalidAddr, this.message);
@@ -783,6 +785,27 @@
            this.exception = null;
            sendPartiallyFailed = false;
            notificationDone = false; // reset for next send
+ }
+ }
+
+ /**
+ * The send failed, fix the address arrays to report the failure
correctly.
+ */
+ private void addressesFailed() {
+ if (validSentAddr != null) {
+ if (validUnsentAddr != null) {
+ Address newa[] =
+ new Address[validSentAddr.length +
validUnsentAddr.length];
+ System.arraycopy(validSentAddr, 0,
+ newa, 0, validSentAddr.length);
+ System.arraycopy(validUnsentAddr, 0,
+ newa, validSentAddr.length,
validUnsentAddr.length);
+ validSentAddr = null;
+ validUnsentAddr = newa;
+ } else {
+ validUnsentAddr = validSentAddr;
+ validSentAddr = null;
+ }
        }
     }