Uploaded image for project: 'JBoss Enterprise Application Platform'
  1. JBoss Enterprise Application Platform
  2. JBEAP-10819

SourceProvider fails to write StreamSource created with StringReader

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 7.1.0.ER3
    • 7.1.0.DR17
    • REST
    • None

      Description:
      org.jboss.resteasy.plugins.providers.SourceProvider fails to write Source into the request/response if the StreamSource constructor StreamSource(Reader reader). As result TransformerException is thrown.

      SourceProvider is trying to convert Source object into StreamSource, assuming Source getInputStream() method will return correct object. This assumption is not met when StreamSource(Reader reader) is used in the request/response, because getInputStream() returns null.

      See the attached reproducer.

      The client request:

      import javax.xml.transform.stream.StreamSource;
      ...
      
      Response response = client.target(PATH).request()
                        .post(Entity.entity(new StreamSource(new StringReader(book)), "application/*+xml"));
      

      The JAX-RS endpoint:

      import javax.xml.transform.Source;
      ...
      
      @POST
      @Path("test")
      @Consumes({"application/*+xml"})
      @Produces({"application/*+xml"})
      public Source testSource(Source mySource) {
      ...
      }
      

      Actual result:

      Caused by: javax.ws.rs.InternalServerErrorException: HTTP 500 Internal Server Error
      	at org.jboss.resteasy.plugins.providers.SourceProvider.writeTo(SourceProvider.java:90)
      	at org.jboss.resteasy.plugins.providers.SourceProvider.writeTo(SourceProvider.java:36)
      	at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.writeTo(AbstractWriterInterceptorContext.java:131)
      	at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:120)
      	at org.jboss.resteasy.plugins.interceptors.encoding.GZIPEncodingInterceptor.aroundWriteTo(GZIPEncodingInterceptor.java:100)
      	at org.jboss.resteasy.core.interception.AbstractWriterInterceptorContext.proceed(AbstractWriterInterceptorContext.java:124)
      	at org.jboss.resteasy.client.jaxrs.internal.ClientInvocation.writeRequestBody(ClientInvocation.java:370)
      	at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.writeRequestBodyToOutputStream(ApacheHttpClient4Engine.java:558)
      	at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.buildEntity(ApacheHttpClient4Engine.java:524)
      	at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.loadHttpMethod(ApacheHttpClient4Engine.java:423)
      	at org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient4Engine.invoke(ApacheHttpClient4Engine.java:281)
      	... 92 more
      Caused by: javax.xml.transform.TransformerException: java.net.MalformedURLException
      	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:749)
      	at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:351)
      	at org.jboss.resteasy.plugins.providers.SourceProvider.writeTo(SourceProvider.java:77)
      	... 102 more
      
      

      Expected result:

              rhn-support-iweiss Ingo Weiss
              kanovotn Katerina Odabasi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: