[ https://issues.apache.org/jira/browse/CASSANDRA-13592?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16064405#comment-16064405 ]
ZhaoYang edited comment on CASSANDRA-13592 at 6/27/17 8:43 AM: --------------------------------------------------------------- In Json path, the bytebuffer is being consumed with position = capacity. So in page-state, no partition key bytes are written. Using bf.duplicate() would fix this issue. {code} public static List<ByteBuffer> rowToJson(List<ByteBuffer> row, ProtocolVersion protocolVersion, ResultSet.ResultMetadata metadata) { StringBuilder sb = new StringBuilder("{"); for (int i = 0; i < metadata.names.size(); i++) { if (i > 0) sb.append(", "); ColumnSpecification spec = metadata.names.get(i); String columnName = spec.name.toString(); if (!columnName.equals(columnName.toLowerCase(Locale.US))) columnName = "\"" + columnName + "\""; ByteBuffer buffer = row.get(i); sb.append('"'); sb.append(Json.quoteAsJsonString(columnName)); sb.append("\": "); if (buffer == null) sb.append("null"); else // use duplicate() to avoid buffer being consumed sb.append(spec.type.toJSONString(buffer.duplicate(), protocolVersion)); } sb.append("}"); return Collections.singletonList(UTF8Type.instance.getSerializer().serialize(sb.toString())); } {code} was (Author: jasonstack): it seems like driver issue.. it swallowed the keys paging state.. > Null Pointer exception at SELECT JSON statement > ----------------------------------------------- > > Key: CASSANDRA-13592 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13592 > Project: Cassandra > Issue Type: Bug > Components: CQL > Environment: Debian Linux > Reporter: Wyss Philipp > Labels: beginner > Attachments: system.log > > > A Nulll pointer exception appears when the command > {code} > SELECT JSON * FROM examples.basic; > ---MORE--- > <Error from server: code=0000 [Server error] > message="java.lang.NullPointerException"> > Examples.basic has the following description (DESC examples.basic;): > CREATE TABLE examples.basic ( > key frozen<tuple<uuid, int>> PRIMARY KEY, > wert text > ) WITH bloom_filter_fp_chance = 0.01 > AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} > AND comment = '' > AND compaction = {'class': > 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', > 'max_threshold': '32', 'min_threshold': '4'} > AND compression = {'chunk_length_in_kb': '64', 'class': > 'org.apache.cassandra.io.compress.LZ4Compressor'} > AND crc_check_chance = 1.0 > AND dclocal_read_repair_chance = 0.1 > AND default_time_to_live = 0 > AND gc_grace_seconds = 864000 > AND max_index_interval = 2048 > AND memtable_flush_period_in_ms = 0 > AND min_index_interval = 128 > AND read_repair_chance = 0.0 > AND speculative_retry = '99PERCENTILE'; > {code} > The error appears after the ---MORE--- line. > The field "wert" has a JSON formatted string. -- This message was sent by Atlassian JIRA (v6.4.14#64029) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org