You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Sergio Bossa (JIRA)" <ji...@apache.org> on 2016/01/21 12:17:39 UTC

[jira] [Commented] (CASSANDRA-11048) JSON queries are not thread safe

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

Sergio Bossa commented on CASSANDRA-11048:
------------------------------------------

Thanks for your patch [~iryndin]. I think it still needs to be improved, here are some suggestions:
1) There's no need to create a {{JsonStringEncoder}} static instance and call {{#getInstance()}} on such instance, as it's a static method.
2) An even better design would be to implement the encoding methods (i.e. {{#quoteAsString()}}) as part of the {{Json}} class, to avoid leaking {{JsonStringEncoder}} instances, which are really an implementation detail.
3) Finally, I would like to see some unit tests showing that {{Json}} methods are now thread safe. 

> JSON queries are not thread safe
> --------------------------------
>
>                 Key: CASSANDRA-11048
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-11048
>             Project: Cassandra
>          Issue Type: Bug
>            Reporter: Sergio Bossa
>            Priority: Critical
>              Labels: easyfix, newbie, patch
>         Attachments: 0001-Fix-thread-unsafe-usage-of-JsonStringEncoder-see-CAS.patch
>
>
> {{org.apache.cassandra.cql3.Json}} uses a shared instance of {{JsonStringEncoder}} which is not thread safe (see 1), while {{JsonStringEncoder#getInstance()}} should be used (see 2).
> As a consequence, concurrent {{select JSON}} queries often produce wrong (sometimes unreadable) results.
> 1. http://grepcode.com/file/repo1.maven.org/maven2/org.codehaus.jackson/jackson-core-asl/1.9.2/org/codehaus/jackson/io/JsonStringEncoder.java
> 2. http://grepcode.com/file/repo1.maven.org/maven2/org.codehaus.jackson/jackson-core-asl/1.9.2/org/codehaus/jackson/io/JsonStringEncoder.java#JsonStringEncoder.getInstance%28%29



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