Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-17107

[Java] JSONFileWriter throws IOOBE writing an empty list

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 8.0.0
    • 9.0.0
    • Java

    Description

      Hey folks,

      I'm trying to write an empty ListVector out through the `JsonFileWriter`, and am getting an IOOBE. Stack trace is as follows:

       

      ```

      java.lang.IndexOutOfBoundsException: index: 0, length: 4 (expected: range(0, 0))
       at org.apache.arrow.memory.ArrowBuf.checkIndexD (ArrowBuf.java:318)
          org.apache.arrow.memory.ArrowBuf.chk (ArrowBuf.java:305)
          org.apache.arrow.memory.ArrowBuf.getInt (ArrowBuf.java:424)
          org.apache.arrow.vector.ipc.JsonFileWriter.writeValueToGenerator (JsonFileWriter.java:270)
          org.apache.arrow.vector.ipc.JsonFileWriter.writeFromVectorIntoJson (JsonFileWriter.java:237)
          org.apache.arrow.vector.ipc.JsonFileWriter.writeFromVectorIntoJson (JsonFileWriter.java:253)
          org.apache.arrow.vector.ipc.JsonFileWriter.writeFromVectorIntoJson (JsonFileWriter.java:253)
          org.apache.arrow.vector.ipc.JsonFileWriter.writeFromVectorIntoJson (JsonFileWriter.java:253)
          org.apache.arrow.vector.ipc.JsonFileWriter.writeBatch (JsonFileWriter.java:200)
          org.apache.arrow.vector.ipc.JsonFileWriter.write (JsonFileWriter.java:190)

      ```

      It's trying to write the offset buffer of the list, which is empty. L224 of JFW.java sets `bufferValueCount` to 1 (because we're not a DUV), so we enter the `for` loop. We don't hit the `valueCount=0` condition in L230 (because we're not a varbinary or a varchar vector). So we fall into the `else`, which tries to write the 0th element in the offset vector, and IOOBE.

      Could we include 'list' in either the L224 or the L230 checks?

      Admittedly, I'm not aware of the history of this section, but it seems that, by the time we hit L230 (i.e. excluding DUV), any empty vector should yield a single 0?

      Let me know if there's any more info I can provide!

      Cheers,

      James

      Attachments

        Issue Links

          Activity

            People

              lidavidm David Li
              jarohen James Henderson
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 20m
                  1h 20m

                  Slack

                    Issue deployment