thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Benjamin Gould (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4082) Java library can't parse JSON generated by javascript TJSONProtocol
Date Sat, 11 Feb 2017 05:02:41 GMT

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

Benjamin Gould commented on THRIFT-4082:
----------------------------------------

I used a Java server with browser Javascript all the time, with no issues.  You might be right
about the code in a try/catch for ProcessFunction.process()... if there is code being generated
there and it doesn't have readStructEnd() that would be a problem.  You are also correct about
this not being an issue for the binary protocol; for that protocol readStructEnd() is a no-op
function:

https://github.com/apache/thrift/blob/e1832c354391deb0e0ce94a62ff32e8ce1c83fd3/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java#L246

IIRC in the Thrift whitepaper it explicitly says readStructEnd() was not strictly necessary
to add to the Thrift semantics (because they included a STOP field) but it was included anyways
to facilitate things like JSON and XML that have both initiating and terminating delimiters
for their structures.

It is also possible this is not covered by the Thrift test suite... there is a phantomjs test
runner for the javascript library but it doesn't look like there is an HTTP transport for
Java in tests.json so I presume this combination does not get tested.  However I would sort
of expect that some test combination does end up testing the JSON protocol with Java so if
there is a bug in the Java implementation here, I think it is possible that this is an edge
case for which there is not test coverage.

> Java library can't parse JSON generated by javascript TJSONProtocol
> -------------------------------------------------------------------
>
>                 Key: THRIFT-4082
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4082
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Compiler
>    Affects Versions: 0.10.0
>            Reporter: Christopher Wright
>            Priority: Critical
>
> Thrift definition:
> struct Entity {
>   1: string id;
> }
> service EntityService {
>   void save(1: Entity entity);
> }
> JSON document: [1,"save",1,0,{"1":{"rec":{"1":{"str":"q19786052"}}}}]
> Error:
> org.apache.thrift.protocol.TProtocolException: Unexpected character:}
> (Additionally, the parser would ideally state where it found the unexpected character.)



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message