You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jl...@apache.org on 2006/03/02 15:23:17 UTC
svn commit: r382389 -
/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java
Author: jlaskowski
Date: Thu Mar 2 06:23:02 2006
New Revision: 382389
URL: http://svn.apache.org/viewcvs?rev=382389&view=rev
Log:
GERONIMO-1670: SMTPTransport not throwing correct exception for message send failures
Modified:
geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java
Modified: geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java
URL: http://svn.apache.org/viewcvs/geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java?rev=382389&r1=382388&r2=382389&view=diff
==============================================================================
--- geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java (original)
+++ geronimo/trunk/modules/javamail-transport/src/java/org/apache/geronimo/javamail/transport/smtp/SMTPTransport.java Thu Mar 2 06:23:02 2006
@@ -83,7 +83,6 @@
/**
* property keys for top level session properties.
*/
- protected static final String MAIL_HOST = "mail.host";
protected static final String MAIL_LOCALHOST = "mail.localhost";
protected static final String MAIL_SSLFACTORY_CLASS = "mail.SSLSocketFactory.class";
@@ -162,9 +161,6 @@
// the target server port.
protected int port;
- // the transport that created us...this is the source of configuration information.
- protected SMTPTransport transport;
-
// the connection socket...can be a plain socket or SSLSocket, if TLS is being used.
protected Socket socket;
@@ -548,9 +544,6 @@
unsent = (Address[])unsentAddresses.toArray(new Address[0]);
invalid = (Address[])invalidAddresses.toArray(new Address[0]);
- // notify of the error.
- notifyTransportListeners(TransportEvent.MESSAGE_NOT_DELIVERED, sent, unsent, invalid, message);
-
// go reset our connection so we can process additional sends.
resetConnection();
@@ -562,16 +555,34 @@
}
}
+
+ try {
+ // try to send the data
+ sendData(message);
+ } catch (MessagingException e) {
+ // If there's an error at this point, this is a complete delivery failure.
+ // we send along the valid and invalid address lists on the notifications and
+ // exceptions.
+ // however, since we're aborting the entire send, the successes need to become
+ // members of the failure list.
+ unsentAddresses.addAll(sentAddresses);
+
+ // this one is empty.
+ sent = new Address[0];
+ unsent = (Address[])unsentAddresses.toArray(new Address[0]);
+ invalid = (Address[])invalidAddresses.toArray(new Address[0]);
+ // notify of the error.
+ notifyTransportListeners(TransportEvent.MESSAGE_NOT_DELIVERED, sent, unsent, invalid, message);
+ // send a send failure exception.
+ throw new SMTPSendFailedException("DATA", 0, "Send failure", e, sent, unsent, invalid);
+ }
+
+
// create our lists for notification and exception reporting from this point on.
sent = (Address[])sentAddresses.toArray(new Address[0]);
unsent = (Address[])unsentAddresses.toArray(new Address[0]);
invalid = (Address[])invalidAddresses.toArray(new Address[0]);
- // send data
- if (!sendData(message)) {
- throw new MessagingException("Error sending data");
- }
-
// if sendFailure is true, we had an error during the address phase, but we had permission to
// process this as a partial send operation. Now that the data has been sent ok, it's time to
@@ -1240,13 +1251,13 @@
* server is in the right place and ready for getting the DATA message
* and the data right place in the sequence
*/
- protected boolean sendData(Message msg) throws MessagingException {
+ protected void sendData(Message msg) throws MessagingException {
// send the DATA command
SMTPReply line = sendCommand("DATA");
if (line.isError()) {
- return false;
+ throw new MessagingException("Error issuing SMTP 'DATA' command: " + line);
}
// now the data... I could look at the type, but
@@ -1272,7 +1283,9 @@
throw new MessagingException(e.toString());
}
- return !line.isError();
+ if (line.isError()) {
+ throw new MessagingException("Error issuing SMTP 'DATA' command: " + line);
+ }
}
/**
@@ -1860,7 +1873,7 @@
int delimiter = extension.indexOf(' ');
// if we have a keyword with arguments, parse them out and add to the argument map.
if (delimiter != -1) {
- extensionName = extension.substring(0, delimiter);
+ extensionName = extension.substring(0, delimiter).toUpperCase();
argument = extension.substring(delimiter + 1);
}