[EMAIL PROTECTED] ha scritto:
Author: rdonkin
Date: Sun Aug  3 14:21:45 2008
New Revision: 682219

URL: http://svn.apache.org/viewvc?rev=682219&view=rev
Log:
Concurrency tests for IMAP
> [...]
Modified:
    
james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java
[...]

This commit included the changes you did to MailImpl working on JAMES-850. I don't know if this is by purpose or by mistake, but I'm not sure they are good in the long term unless there is a need (unless they fix the issue, because the "full clone" on MailImpl was introduced for performance issues).

Stefano

Modified: 
james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java?rev=682219&r1=682218&r2=682219&view=diff
==============================================================================
--- 
james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java
 (original)
+++ 
james/server/trunk/core-library/src/main/java/org/apache/james/core/MailImpl.java
 Sun Aug  3 14:21:45 2008
@@ -28,6 +28,7 @@
 import org.apache.mailet.RFC2822Headers;
import javax.mail.MessagingException;
+import javax.mail.SendFailedException;
 import javax.mail.internet.InternetAddress;
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.ParseException;
@@ -158,16 +159,19 @@
         setRemoteAddr(mail.getRemoteAddr());
         setLastUpdated(mail.getLastUpdated());
         try {
-            if (mail instanceof MailImpl) {
-                setAttributesRaw((HashMap) cloneSerializableObject(((MailImpl) 
mail).getAttributesRaw()));
-            } else {
-                HashMap attribs = new HashMap();
-                for (Iterator i = mail.getAttributeNames(); i.hasNext(); ) {
-                    String hashKey = (String) i.next();
-                    
attribs.put(hashKey,cloneSerializableObject(mail.getAttribute(hashKey)));
+            HashMap attribs = new HashMap();
+            for (Iterator i = mail.getAttributeNames(); i.hasNext(); ) {
+                String hashKey = (String) i.next();
+                final Serializable attribute = mail.getAttribute(hashKey);
+                if (attribute instanceof SendFailedException) {
+                    SendFailedException ex = (SendFailedException) attribute;
+                    Throwable t = ex.getNextException();
+ debug(t); }
-                setAttributesRaw(attribs);
+                final Object cloneSerializableObject = 
cloneSerializableObject(attribute);
+                attribs.put(hashKey,cloneSerializableObject);
             }
+            setAttributesRaw(attribs);
         } catch (IOException e) {
             // should never happen for in memory streams
             setAttributesRaw(new HashMap());
@@ -176,6 +180,28 @@
             setAttributesRaw(new HashMap());
         }
     }
+    private void debug(Throwable t) {
+        if (t == null) {
+            System.err.println("[END]");
+        } else {
+            System.err.println("NEXT@" + System.identityHashCode(t)  + t );
+            if (t instanceof MessagingException) {
+                MessagingException e = (MessagingException) t;
+                System.err.println("NEXT@" + System.identityHashCode(e)  + e );
+                t = e.getNextException();
+                if (t == null) {
+                    t = e.getCause();
+                }
+                debug(t);
+            } else {
+                System.err.println("NEXT@" + System.identityHashCode(t)  + t );
+                Throwable next = t.getCause();
+                if (next != t) {
+                    debug(next);
+                }
+            }
+        }
+    }
/**
      * A constructor that creates a MailImpl with the specified name,
@@ -608,7 +634,7 @@
      * @throws IOException
      * @throws ClassNotFoundException
      */
-    private static Object cloneSerializableObject(Object o) throws 
IOException, ClassNotFoundException {
+    public static Object cloneSerializableObject(Object o) throws IOException, 
ClassNotFoundException {
         ByteArrayOutputStream b = new ByteArrayOutputStream();
         ObjectOutputStream out = new ObjectOutputStream(b);
         out.writeObject(o);
[...]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to