axis-java-dev mailing list archives

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

  A new issue has been created in JIRA.

---------------------------------------------------------------------
View the issue:
  http://issues.apache.org/jira/browse/AXIS-1328

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
   Versions:
             1.1
             1.2 Beta

   Assignee: 
   Reporter: Paulo Soares

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

Description:
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


---------------------------------------------------------------------
JIRA INFORMATION:
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

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira


Mime
View raw message