Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-5846

ClassCastException in org.apache.cxf.jaxrs.provider.BinaryDataProvider & SourceProvider

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0
    • 2.7.13, 3.0.2, 3.1
    • None
    • None
    • Unknown

    Description

      1. Using Reader's Implementation BufferedReader:
      @POST
      @Path("/subclasses/shouldfail")
      public BufferedReader postReader(BufferedReader br)

      { return br; }

      Exception stack:
      Caused by: java.lang.ClassCastException: Cannot cast class java.io.InputStreamReader to class java.io.BufferedReader
      at java.lang.Class.cast(Class.java:1730)
      at org.apache.cxf.jaxrs.provider.BinaryDataProvider.readFrom(BinaryDataProvider.java:77)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1311)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1262)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:801)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:764)
      at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212)
      at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:76)
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
      ... 19 more

      2. Using ByteArrayInputStream:
      @POST
      @Path("/subclasses/shouldfail")
      public ByteArrayInputStream postInputStream(ByteArrayInputStream is)

      { return is; }

      Exception stack:
      Caused by: java.lang.ClassCastException: Cannot cast class org.apache.cxf.transport.http.AbstractHTTPDestination$1 to class java.io.ByteArrayInputStream
      at java.lang.Class.cast(Class.java:1730)
      at org.apache.cxf.jaxrs.provider.BinaryDataProvider.readFrom(BinaryDataProvider.java:74)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1311)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1262)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:801)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:764)
      at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212)
      at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:76)
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
      ... 19 more

      3. Using Source's implmentation class:
      public static class UnsupportedSourceSubclass implements Source {

      public String getSystemId()

      { return null; }

      public void setSystemId(String systemId) {
      }
      }
      @POST
      @Path("/subclasses/shouldfail")
      public UnsupportedSourceSubclass postReader(UnsupportedSourceSubclass saxSource)

      { return saxSource; }

      Exception stack:
      Caused by: java.lang.ClassCastException: Cannot cast class javax.xml.transform.stream.StreamSource to class com.test.jaxrs.fat.standard.SourceResource$UnsupportedSourceSubclass
      at java.lang.Class.cast(Class.java:1730)
      at org.apache.cxf.jaxrs.provider.SourceProvider.readFrom(SourceProvider.java:115)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBodyReader(JAXRSUtils.java:1311)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.readFromMessageBody(JAXRSUtils.java:1262)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameter(JAXRSUtils.java:801)
      at org.apache.cxf.jaxrs.utils.JAXRSUtils.processParameters(JAXRSUtils.java:764)
      at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.processRequest(JAXRSInInterceptor.java:212)
      at org.apache.cxf.jaxrs.interceptor.JAXRSInInterceptor.handleMessage(JAXRSInInterceptor.java:76)
      at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)
      ... 19 more

      Attachments

        1. cxf-5846.patch
          36 kB
          Iris Ding

        Activity

          People

            sergey_beryozkin Sergey Beryozkin
            irisding Iris Ding
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: