You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Davanum Srinivas (JIRA)" <ax...@ws.apache.org> on 2005/07/27 22:17:28 UTC

[jira] Resolved: (AXIS-1328) AttachmentPart.getSize() reads all the file to memory

     [ http://issues.apache.org/jira/browse/AXIS-1328?page=all ]
     
Davanum Srinivas resolved AXIS-1328:
------------------------------------

    Resolution: Won't Fix

getSize() is *NOT* called if you use CommonsHTTPSender (which uses HTTP1.1).

thanks,
dims

> AttachmentPart.getSize() reads all the file to memory
> -----------------------------------------------------
>
>          Key: AXIS-1328
>          URL: http://issues.apache.org/jira/browse/AXIS-1328
>      Project: Apache Axis
>         Type: Improvement
>     Versions: 1.1, 1.2 Beta
>  Environment: All evironments
>     Reporter: Paulo Soares

>
> AttachmentPart.getSize() reads all the attachment file to memory to determine the size. If the attachment is big an out of memory exception will occur. A solution can be:
>     public int getSize() throws SOAPException {
>         if (datahandler == null) {
>             return 0;
>         }
>         InputStream is = null;
>         int total = 0;
>         try {
>             byte buf[] = new byte[8192];
>             is = datahandler.getInputStream();
>             int n;
>             while ((n = is.read(buf)) >= 0)
>                 total += n;
>         } catch (java.io.IOException ex) {
>             log.error(Messages.getMessage("javaIOException00"), ex);
>             throw new SOAPException(Messages.getMessage("javaIOException01", ex.getMessage()), ex);
>         }
>         finally {
>             try{is.close();}catch(Exception e){}
>         }
>         return total;
>     }
> Best Regards,
> Paulo Soares

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira