You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Thanh (Jira)" <ji...@apache.org> on 2020/05/15 20:49:00 UTC
[jira] [Commented] (CASSANDRA-14200) NullPointerException when
dumping sstable with null value for timestamp column
[ https://issues.apache.org/jira/browse/CASSANDRA-14200?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17108649#comment-17108649 ]
Thanh commented on CASSANDRA-14200:
-----------------------------------
You can see the NPE by inserting data using JSON like this:
{code:java}
create table tsest3(id int PRIMARY KEY ,fname text, lname text, ts_field1 timestamp, dept text, ts_field2 timestamp);
insert into tsest3 JSON '{"id":7,"fname":"sally","lname":"field","ts_field1":"","dept":"dept1","ts_field2":null}';{code}
The problem is introduced when you try setting a timestamp field to null using
JSON '\{"ts_field1":""}' //this will give sstabledump NPE
instead of
JSON '\{"ts_field1":null}' //this is fine, no NPE here
> NullPointerException when dumping sstable with null value for timestamp column
> ------------------------------------------------------------------------------
>
> Key: CASSANDRA-14200
> URL: https://issues.apache.org/jira/browse/CASSANDRA-14200
> Project: Cassandra
> Issue Type: Bug
> Components: Legacy/Core
> Reporter: Simon Zhou
> Assignee: Simon Zhou
> Priority: Normal
> Fix For: 3.0.x
>
>
> We have an sstable whose schema has a column of type timestamp and it's not part of primary key. When dumping the sstable using sstabledump there is NPE like this:
> {code:java}
> Exception in thread "main" java.lang.NullPointerException
> at java.util.Calendar.setTime(Calendar.java:1770)
> at java.text.SimpleDateFormat.format(SimpleDateFormat.java:943)
> at java.text.SimpleDateFormat.format(SimpleDateFormat.java:936)
> at java.text.DateFormat.format(DateFormat.java:345)
> at org.apache.cassandra.db.marshal.TimestampType.toJSONString(TimestampType.java:93)
> at org.apache.cassandra.tools.JsonTransformer.serializeCell(JsonTransformer.java:442)
> at org.apache.cassandra.tools.JsonTransformer.serializeColumnData(JsonTransformer.java:376)
> at org.apache.cassandra.tools.JsonTransformer.serializeRow(JsonTransformer.java:280)
> at org.apache.cassandra.tools.JsonTransformer.serializePartition(JsonTransformer.java:215)
> at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
> at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:175)
> at java.util.Iterator.forEachRemaining(Iterator.java:116)
> at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1801)
> at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
> at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
> at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
> at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
> at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
> at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
> at org.apache.cassandra.tools.JsonTransformer.toJson(JsonTransformer.java:104)
> at org.apache.cassandra.tools.SSTableExport.main(SSTableExport.java:242){code}
> The reason is that we use a null Date when there is no value for this column:
> {code}
> public Date deserialize(ByteBuffer bytes)
> {
> return bytes.remaining() == 0 ? null : new Date(ByteBufferUtil.toLong(bytes));
> }
> {code}
> It seems that we should not deserialize columns with null values.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cassandra.apache.org
For additional commands, e-mail: commits-help@cassandra.apache.org