FileManagerService unicity API should not load the complete content of a 
streaming blob into memory
---------------------------------------------------------------------------------------------------

                 Key: NXP-1979
                 URL: http://jira.nuxeo.org/browse/NXP-1979
             Project: Nuxeo Enterprise Platform 5
          Issue Type: Bug
          Components: Web Foundations
    Affects Versions: 5.1.2, 5.1.3
            Reporter: Olivier Grisel
            Assignee: Laurent Doguin
             Fix For: 5.1.4


The offending code lives in FileManagerService:

    public String computeDigest(Blob blob) {
        try {
            MessageDigest md = MessageDigest.getInstance(algo);
            // XXX: OG: why load the content of a complete blob in memory here,
            // this will exhaust heap space with huge Blobs?
            md.update(blob.getByteArray());
            byte[] b = md.digest();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < b.length; i++) {
                sb.append(b[i]);
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException e) {
            log.error("Digest Algortihm " + algo + " doesn't exist.");
        } catch (IOException e) {
            log.error(e);
        }

blob.getByteArray() will exhaust heap space on big streaming blobs.

Furthermore this method should not catch unexpected exceptions.

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

        
_______________________________________________
ECM-tickets mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm-tickets

Reply via email to