Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-14200

NullPointerException when dumping sstable with null value for timestamp column

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Normal
    • Resolution: Duplicate
    • 3.0.22
    • Legacy/Core
    • None
    • Normal

    Description

      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:

      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)

      The reason is that we use a null Date when there is no value for this column:

          public Date deserialize(ByteBuffer bytes)
          {
              return bytes.remaining() == 0 ? null : new Date(ByteBufferUtil.toLong(bytes));
          }
      

      It seems that we should not deserialize columns with null values.

      Attachments

        Issue Links

          Activity

            People

              bereng Berenguer Blasi
              szhou Simon Zhou
              Berenguer Blasi
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: