Details

    • Type: Service Pack Request
    • Status: Closed
    • Resolution: Fixed
    • Affects Version/s: 5.0, 5.1, 5.2, 6.0
    • Fix Version/s: 5.2.5, 6.0.1
    • Component/s: ACS REST API
    • Labels:
    • Bug Priority:
      Category 1
    • ACT Numbers:

      00988301

      Description

      When downloading a large file via the V1 REST API:
      /alfresco/api/default/public/alfresco/versions/1/nodes/<nodeid>/content?attachment=true&alf_ticket=<ticket>
      the server OOMs with this stack trace:

      Caused by: java.lang.OutOfMemoryError: Java heap space
      	at java.util.Arrays.copyOf(Arrays.java:3236)
      	at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
      	at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
      	at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
      	at org.springframework.util.StreamUtils.copy(StreamUtils.java:140)
      	at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:107)
      	at org.alfresco.repo.content.AbstractContentReader.getContent(AbstractContentReader.java:423)
      	at org.alfresco.repo.web.scripts.content.ContentStreamer.streamContentImpl(ContentStreamer.java:443)
      	at org.alfresco.repo.web.scripts.content.ContentStreamer.streamContent(ContentStreamer.java:268)
      	at org.alfresco.rest.framework.webscripts.AbstractResourceWebScript.streamResponse(AbstractResourceWebScript.java:199)
      	at org.alfresco.rest.framework.webscripts.AbstractResourceWebScript.execute(AbstractResourceWebScript.java:137)
      	at org.alfresco.rest.framework.webscripts.ApiWebScript.execute(ApiWebScript.java:113)
      	at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecute(RepositoryContainer.java:467)
      	at org.alfresco.rest.api.PublicApiRepositoryContainer.transactionedExecute(PublicApiRepositoryContainer.java:70)
      	at org.alfresco.repo.web.scripts.RepositoryContainer.transactionedExecuteAs(RepositoryContainer.java:656)
      	at org.alfresco.repo.web.scripts.RepositoryContainer.executeScriptInternal(RepositoryContainer.java:428)
      	at org.alfresco.repo.web.scripts.RepositoryContainer.executeScript(RepositoryContainer.java:308)
      	at org.alfresco.rest.api.PublicApiRepositoryContainer.access$001(PublicApiRepositoryContainer.java:51)
      	at org.alfresco.rest.api.PublicApiRepositoryContainer$1.doWork(PublicApiRepositoryContainer.java:106)
      	at org.alfresco.repo.tenant.TenantUtil.runAsWork(TenantUtil.java:126)
      	at org.alfresco.repo.tenant.TenantUtil.runAsTenant(TenantUtil.java:95)
      	at org.alfresco.rest.api.PublicApiRepositoryContainer.executeScript(PublicApiRepositoryContainer.java:102)
      	at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:399)
      	at org.springframework.extensions.webscripts.AbstractRuntime.executeScript(AbstractRuntime.java:210)
      	at org.alfresco.repo.web.scripts.TenantWebScriptServlet.service(TenantWebScriptServlet.java:82)
      	at org.alfresco.rest.api.PublicApiWebScriptServlet.service(PublicApiWebScriptServlet.java:62)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
      	at sun.reflect.GeneratedMethodAccessor641.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:282)
      	at org.apache.catalina.security.SecurityUtil$1.run(SecurityUtil.java:279)
      

      This indicates that the RestAPI is not streaming the data directly to the HttpServletResponse, but to an intermediate ByteArrayOutputStream.

      This intermediate ByteArrayOutputStream is introduced by the transaction handling here:
      https://github.com/Alfresco/alfresco-remote-api/blob/master/src/main/java/org/alfresco/repo/web/scripts/RepositoryContainer.java#L483

      These buffers are triggered by the ReadWrite transaction.

      Instead, this download should be done in a ReadOnly transaction.

      Check also other downloads in the API, like renditions.

        Attachments

          Issue Links

            Structure

              Activity

                People

                • Assignee:
                  closedbugs Closed Bugs (Inactive)
                  Reporter:
                  skopf Stefan Kopf
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:

                    Structure Helper Panel