Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-992

Client gives out of memory error, if consuming a huge multipart form via POST

    XMLWordPrintable

    Details

    • Steps to Reproduce:
      Hide

      Download with the RESTEasy Java Client a huge MultipartFormDataInput from a RESTEasy RESTService.

      Show
      Download with the RESTEasy Java Client a huge MultipartFormDataInput from a RESTEasy RESTService.
    • Workaround:
      Workaround Exists
    • Workaround Description:
      Hide

      Use as a Client the apache HTTP Client. Parse the stream with org.apache.commons.fileupload.MultipartStream.

      Show
      Use as a Client the apache HTTP Client. Parse the stream with org.apache.commons.fileupload.MultipartStream.
    • Estimated Difficulty:
      High

      Description

      A client sided

      MultipartFormDataInput input = aResult.readEntity(MultipartFormDataInput.class);

      results in an out of memory error if a huge file-stream is downloaded (from an RESTEasy RESTService) The same big file uploaded to the RESTEasy Service is handled well.

      Server side:

      @POST
      @Path("/xxx")
      @Produces("multipart/form-data")
      @Consumes("multipart/form-data")
      public MultipartFormDataOutput uploadAndDownloadFile( MultipartFormDataInput input)

      {...}

      InputStream input = aResult.readEntity(InputStream.class);
      does not solve the problem, even if you try to consume the stream with
      a org.apache.commons.fileupload.MultipartStream.

      Stack trace:

      Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
      at java.io.BufferedInputStream.fill(Unknown Source)
      at java.io.BufferedInputStream.read1(Unknown Source)
      at java.io.BufferedInputStream.read(Unknown Source)
      at org.jboss.resteasy.client.core.SelfExpandingBufferredInputStream.read(SelfExpandingBufferredInputStream.java:57)
      at java.io.SequenceInputStream.read(Unknown Source)
      at org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:94)
      at org.apache.james.mime4j.io.MimeBoundaryInputStream.fillBuffer(MimeBoundaryInputStream.java:196)
      at org.apache.james.mime4j.io.MimeBoundaryInputStream.read(MimeBoundaryInputStream.java:127)
      at org.apache.james.mime4j.io.BufferedLineReaderInputStream.fillBuffer(BufferedLineReaderInputStream.java:94)
      at org.apache.james.mime4j.io.BufferedLineReaderInputStream.read(BufferedLineReaderInputStream.java:137)
      at org.apache.james.mime4j.io.LineReaderInputStreamAdaptor.read(LineReaderInputStreamAdaptor.java:67)
      at java.io.FilterInputStream.read(Unknown Source)
      at org.apache.james.mime4j.codec.CodecUtil.copy(CodecUtil.java:42)
      at org.apache.james.mime4j.storage.AbstractStorageProvider.store(AbstractStorageProvider.java:57)
      at org.apache.james.mime4j.message.BodyFactory.binaryBody(BodyFactory.java:92)
      at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryOnlyMessageBuilder.body(MultipartInputImpl.java:132)
      at org.apache.james.mime4j.parser.MimeStreamParser.parse(MimeStreamParser.java:101)
      at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:153)
      at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl$BinaryMessage.<init>(MultipartInputImpl.java:146)
      at org.jboss.resteasy.plugins.providers.multipart.MultipartInputImpl.parse(MultipartInputImpl.java:197)
      at org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:52)
      at org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataReader.readFrom(MultipartFormDataReader.java:20)
      at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.readFrom(AbstractReaderInterceptorContext.java:59)
      at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:51)
      at org.jboss.resteasy.plugins.interceptors.encoding.GZIPDecodingInterceptor.aroundReadFrom(GZIPDecodingInterceptor.java:59)
      at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
      at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:244)
      at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:178)
      at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:217)
      at test.Main.testResteasy(Main.java:142)
      at test.Main.main(Main.java:59)

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  bill.burke Bill Burke
                  Reporter:
                  ruenagel_frank Frank Ruenagel
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: