[ 
https://issues.apache.org/jira/browse/CXF-6179?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Sergey Beryozkin resolved CXF-6179.
-----------------------------------
    Resolution: Won't Fix
      Assignee: Sergey Beryozkin

Using TransformFeature implies that message body readers can work with custom 
XMLStreamReader

> Jackson JSON parsing Incompatible with the Transform Feature
> ------------------------------------------------------------
>
>                 Key: CXF-6179
>                 URL: https://issues.apache.org/jira/browse/CXF-6179
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-RS
>    Affects Versions: 3.0.3
>         Environment: CXF 3.0.3 and Jackson 2.4.4
>            Reporter: Chris Marshall
>            Assignee: Sergey Beryozkin
>
> Short version of the problem:
>      Jackson (2.4.4) when used to parse inbound JSON messages is incompatible 
> with the transform feature (CXF 3.0.3).  The transform feature 
> (org.apache.cxf.feature.StaxTransformFeature) consumes the InputStream that 
> jackson expects to read with the JSON content.
> Longer version of the problem:
>      I am currently building a service that is to be used by parterners that 
> will be using various different tools, for example PHP and Windows .NET.  As 
> a consequence I would like to create a service that support SOAP, Rest/XML 
> and Rest/JSON.  The Rest versions should support messages both with and 
> without namespaces.  At this point I have working SOAP, Rest/JSON and 
> Rest/XML with namespaces.  In order to get Rest/XML without namespaces to 
> work I added the use of the transform feature and it behaves as desired with 
> XML.  However as soon as the transform feature is enabled the JSON parsing 
> quits working.  Digging into what is going on, the point at which Jackson 
> tries to read the InputStream there are 0 available bytes when the transform 
> feature is enabled.
>      In order to diagnose the issue I overrode the readFrom method in 
> com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider as follows:
> package com.a100sys.affiliateportal.impl;
> import java.io.IOException;
> import java.io.InputStream;
> import java.lang.annotation.Annotation;
> import java.lang.reflect.Type;
> import javax.ws.rs.Consumes;
> import javax.ws.rs.Produces;
> import javax.ws.rs.core.MediaType;
> import javax.ws.rs.core.MultivaluedMap;
> import javax.ws.rs.ext.Provider;
> import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
> @Provider
> @Consumes(MediaType.WILDCARD) // NOTE: required to support "non-standard" 
> JSON variants
> @Produces(MediaType.WILDCARD)
> public class JsonTestProvider extends JacksonJaxbJsonProvider {
>       @Override
>       public Object readFrom(Class<Object> arg0, Type arg1, Annotation[] arg2,
>                       MediaType arg3, MultivaluedMap<String, String> arg4,
>                       InputStream arg5) throws IOException {
>               int availableBytes = arg5.available();
>               System.out.println("Available bytes " + availableBytes);
>               Object readObject = super.readFrom(arg0, arg1, arg2, arg3, 
> arg4, arg5);
>               return readObject;
>       }
>       
> }
> In my test case without the transform feature enabled there are a nice 
> healthy 731 bytes available and when the transform feature is enable there 
> are 0 available bytes.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to