You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2010/10/25 18:02:50 UTC
svn commit: r1027175 - in
/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets:
DSNBounce.java RemoteDelivery.java
Author: norman
Date: Mon Oct 25 16:02:50 2010
New Revision: 1027175
URL: http://svn.apache.org/viewvc?rev=1027175&view=rev
Log:
Store exception text as string to fix classcastexception (JAMES-1086)
Modified:
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java?rev=1027175&r1=1027174&r2=1027175&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java (original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/DSNBounce.java Mon Oct 25 16:02:50 2010
@@ -279,10 +279,10 @@ public class DSNBounce extends AbstractN
for (Iterator i = originalMail.getRecipients().iterator(); i.hasNext(); ) {
out.println(i.next());
}
- MessagingException ex = (MessagingException)originalMail.getAttribute("delivery-error");
+ String ex = (String)originalMail.getAttribute("delivery-error");
out.println();
out.println("Error message:");
- out.println(getErrorMsg(ex));
+ out.println(ex);
out.println();
part1.setText(sout.toString());
@@ -364,9 +364,8 @@ public class DSNBounce extends AbstractN
//required: status
// get Exception for getting status information
// TODO: it would be nice if the SMTP-handler would set a status attribute we can use here
- MessagingException ex =
- (MessagingException) originalMail.getAttribute("delivery-error");
- out.println("Status: "+getStatus(ex));
+ String ex =(String) originalMail.getAttribute("delivery-error");
+ out.println("Status: "+ ex);
//optional: remote MTA
//to which MTA were we talking while the Error occured?
@@ -377,7 +376,7 @@ public class DSNBounce extends AbstractN
// (or other transport) communication
// and should be stored as attribute by the smtp handler
// but until now we only have error-messages.
- String diagnosticCode = getErrorMsg(ex);
+ String diagnosticCode = ex;
// Sometimes this is the smtp diagnostic code,
// but James often gives us other messages
Perl5Matcher diagMatcher = new Perl5Matcher();
@@ -545,20 +544,7 @@ public class DSNBounce extends AbstractN
}
}
- /**
- * Utility method for getting the error message from the (nested) exception.
- *
- * @param me MessagingException
- * @return error message
- */
- protected String getErrorMsg(MessagingException me) {
- if (me.getNextException() == null) {
- return me.getMessage().trim();
- } else {
- Exception ex1 = me.getNextException();
- return ex1.getMessage().trim();
- }
- }
+
public String getMailetInfo() {
Modified: james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java
URL: http://svn.apache.org/viewvc/james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java?rev=1027175&r1=1027174&r2=1027175&view=diff
==============================================================================
--- james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java (original)
+++ james/server/trunk/mailets/src/main/java/org/apache/james/transport/mailets/RemoteDelivery.java Mon Oct 25 16:02:50 2010
@@ -1425,7 +1425,13 @@ public class RemoteDelivery extends Gene
if (bounceProcessor != null) {
// do the new DSN bounce
// setting attributes for DSN mailet
- mail.setAttribute("delivery-error", ex);
+ String cause;
+ if (ex instanceof MessagingException) {
+ cause = getErrorMsg((MessagingException)ex);
+ } else {
+ cause = ex.getMessage();
+ }
+ mail.setAttribute("delivery-error", cause);
mail.setState(bounceProcessor);
// re-insert the mail into the spool for getting it passed to the dsn-processor
MailetContext mc = getMailetContext();
@@ -1442,6 +1448,21 @@ public class RemoteDelivery extends Gene
return true;
}
+ /**
+ * Utility method for getting the error message from the (nested) exception.
+ *
+ * @param me MessagingException
+ * @return error message
+ */
+ protected String getErrorMsg(MessagingException me) {
+ if (me.getNextException() == null) {
+ return me.getMessage().trim();
+ } else {
+ Exception ex1 = me.getNextException();
+ return ex1.getMessage().trim();
+ }
+ }
+
private void bounce(Mail mail, Exception ex) {
StringWriter sout = new StringWriter();
PrintWriter out = new PrintWriter(sout, true);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org