axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [jira] Created: (AXIS-1328) AttachmentPart.getSize() reads all the file to memory
Date Wed, 21 Apr 2004 10:56:53 GMT

  A new issue has been created in JIRA.

View the issue:

Here is an overview of the issue:
        Key: AXIS-1328
    Summary: AttachmentPart.getSize() reads all the file to memory
       Type: Improvement

     Status: Unassigned
   Priority: Major

    Project: Axis
             1.2 Beta

   Reporter: Paulo Soares

    Created: Wed, 21 Apr 2004 3:56 AM
    Updated: Wed, 21 Apr 2004 3:56 AM
Environment: All evironments

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 = >= 0)
                total += n;
        } catch ( ex) {
            log.error(Messages.getMessage("javaIOException00"), ex);
            throw new SOAPException(Messages.getMessage("javaIOException01", ex.getMessage()),
        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:

If you want more information on JIRA, or have a bug to report see:

View raw message