dims        2003/06/27 11:19:44

  Modified:    java/src/org/apache/axis/attachments AttachmentsImpl.java
  Log:
  Fix for Bug 20704 - AttachmentsImpl adds duplicate copies of an attachment part.
  from [EMAIL PROTECTED] (Toshiyuki Kimura)
  
  Revision  Changes    Path
  1.41      +15 -0     
xml-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java
  
  Index: AttachmentsImpl.java
  ===================================================================
  RCS file: 
/home/cvs/xml-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- AttachmentsImpl.java      19 Jun 2003 04:51:57 -0000      1.40
  +++ AttachmentsImpl.java      27 Jun 2003 18:19:44 -0000      1.41
  @@ -103,6 +103,11 @@
        */
       protected String contentLocation = null;
   
  +     /**
  +      * The HashMap for DataHandler Managements 
  +      */
  +     private HashMap stackDataHandler = new HashMap();
  +
       /**
        * Construct one of these on a parent Message.
        * Should only ever be called by Message constructor!
  @@ -273,6 +278,12 @@
       public Part createAttachmentPart(Object datahandler)
               throws org.apache.axis.AxisFault {
   
  +             // Searching for the same attachements
  +             Integer key = new Integer(datahandler.hashCode());
  +             if (stackDataHandler.containsKey(key)) {
  +                     return (Part)stackDataHandler.get(key);
  +             }
  +
           multipart = null;
   
           dimemultipart = null;
  @@ -291,6 +302,9 @@
   
           addAttachmentPart(ret);
   
  +             // Store the current DataHandler with its key
  +             stackDataHandler.put(key, ret);
  +
           return ret;
       }
   
  @@ -585,6 +599,7 @@
               mergeinAttachments();
               attachments.clear();
               orderedAttachments.clear();
  +            stackDataHandler.clear();
           } catch (AxisFault af){
               log.warn(Messages.getMessage("exception00"));
           }
  
  
  

Reply via email to