Fergus Nelson created CAMEL-6873:
------------------------------------

             Summary: Camel-Gson does not respect Exchange.CHARSET_NAME
                 Key: CAMEL-6873
                 URL: https://issues.apache.org/jira/browse/CAMEL-6873
             Project: Camel
          Issue Type: Bug
          Components: camel-gson
    Affects Versions: 2.12.0
            Reporter: Fergus Nelson


When marshalling and unmarshalling using the gson component it does not respect 
the Excahnge.CHARSET_NAME property on the exchange. When constructing the 
Streams the charset should be passed. My changes are highlighted below. Git 
pull request to follow.

    @Override
    public void marshal(final Exchange exchange, final Object graph, final 
OutputStream stream) throws Exception {
        BufferedWriter writer = IOHelper.buffered(new 
OutputStreamWriter(stream{color:red}, 
IOHelper.getCharsetName(exchange){color}));
        gson.toJson(graph, writer);
        writer.close();
    }

    @Override
    public Object unmarshal(final Exchange exchange, final InputStream stream) 
throws Exception {
        BufferedReader reader = IOHelper.buffered(new 
InputStreamReader(stream{color:red}, IOHelper.getCharsetName(exchange){color}));
        Object result = gson.fromJson(reader, this.unmarshalType);
        reader.close();
        return result;
    }



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to