[ 
https://issues.apache.org/jira/browse/GEODE-9104?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17311707#comment-17311707
 ] 

Barrett Oglesby commented on GEODE-9104:
----------------------------------------

The query executes this code path:
{noformat}
java.lang.Exception
        at 
org.apache.geode.rest.internal.web.util.JSONUtils.enableDisableJSONGeneratorFeature(JSONUtils.java:57)
        at 
org.apache.geode.rest.internal.web.util.JSONUtils.convertCollectionToJson(JSONUtils.java:141)
        at 
org.apache.geode.rest.internal.web.controllers.AbstractBaseController.processQueryResponse(AbstractBaseController.java:243)
        at 
org.apache.geode.rest.internal.web.controllers.QueryAccessController.runNamedQuery(QueryAccessController.java:262)
{noformat}
JSONUtils creates a JsonGenerator like:
{noformat}
getObjectMapper().getFactory().createGenerator((OutputStream) outputStream, 
JsonEncoding.UTF8)
{noformat}
It then enables the ESCAPE_NON_ASCII feature:
{noformat}
generator.enable(JsonWriteFeature.ESCAPE_NON_ASCII.mappedFeature());
    {noformat}
This is what causes the Chinese characters to be escaped.

The get creates a RegionData in this code path:
{noformat}
java.lang.Exception: RegionData.RegionData
        at 
org.apache.geode.rest.internal.web.controllers.support.RegionData.<init>(RegionData.java:59)
        at 
org.apache.geode.rest.internal.web.controllers.support.RegionEntryData.<init>(RegionEntryData.java:48)
        at 
org.apache.geode.rest.internal.web.controllers.PdxBasedCrudController.getRegionKeys(PdxBasedCrudController.java:260)
        at 
org.apache.geode.rest.internal.web.controllers.PdxBasedCrudController.read(PdxBasedCrudController.java:243)
{noformat}
The RegionData is serialized here:
{noformat}
java.lang.Exception: RegionData.serialize
        at 
org.apache.geode.rest.internal.web.controllers.support.RegionData.serialize(RegionData.java:131)
        at 
com.fasterxml.jackson.databind.ser.std.SerializableSerializer.serialize(SerializableSerializer.java:39)
        at 
com.fasterxml.jackson.databind.ser.std.SerializableSerializer.serialize(SerializableSerializer.java:20)
        at 
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider._serialize(DefaultSerializerProvider.java:480)
        at 
com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:319)
        at 
com.fasterxml.jackson.databind.ObjectWriter$Prefetch.serialize(ObjectWriter.java:1514)
        at 
com.fasterxml.jackson.databind.ObjectWriter.writeValue(ObjectWriter.java:1006)
        at 
org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.writeInternal(AbstractJackson2HttpMessageConverter.java:454)
        at 
org.springframework.http.converter.AbstractGenericHttpMessageConverter.write(AbstractGenericHttpMessageConverter.java:104)
{noformat}
AbstractJackson2HttpMessageConverter.writeInternal creates a JsonGenerator like 
this:
{noformat}
objectMapper.getFactory().createGenerator(outputStream, encoding)
{noformat}
This is the same as JSONUtils. The ESCAPE_NON_ASCII is not enabled in this 
case, though.


> REST query output displays non-ASCII characters using escapes
> -------------------------------------------------------------
>
>                 Key: GEODE-9104
>                 URL: https://issues.apache.org/jira/browse/GEODE-9104
>             Project: Geode
>          Issue Type: Bug
>          Components: rest (dev)
>            Reporter: Barrett Oglesby
>            Assignee: Barrett Oglesby
>            Priority: Major
>
> For example, if JSON containing Chinese characters is put:
> {noformat}
> curl -X PUT -H "Content-Type: application/json" 
> localhost:8081/geode/v1/customers/1 -d '{"id": "1", "firstName": "名", 
> "lastName": "姓"}'
> {noformat}
> The results of getting the entry are correct:
> {noformat}
> curl localhost:8081/geode/v1/customers/1
> {
>   "id" : "1",
>   "firstName" : "名",
>   "lastName" : "姓"
> }
> {noformat}
> The results of querying the entry show the field values escaped:
> {noformat}
> curl -G http://localhost:8081/gemfire-api/v1/queries/adhoc --data-urlencode 
> "q=SELECT * FROM /customers where id='1'"
> [ {
>   "id" : "1",
>   "firstName" : "\u540D",
>   "lastName" : "\u59D3"
> } ]
> {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to