You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@iotdb.apache.org by "PDGGK (via GitHub)" <gi...@apache.org> on 2026/03/31 11:39:23 UTC

[PR] Fix Java client time column access throwing ArrayIndexOutOfBoundsException (#17407) [iotdb]

PDGGK opened a new pull request, #17408:
URL: https://github.com/apache/iotdb/pull/17408

   ## Description
   
   Fixes #17407
   
   This is the Java equivalent of the C++ client fix in #17400.
   
   In `IoTDBRpcDataSet.java`, several `ByTsBlockColumnIndex` getter methods do not handle `tsBlockColumnIndex < 0` (the time pseudo-column in tree model). Only `getLongByTsBlockColumnIndex` and `getStringByTsBlockColumnIndex` correctly handle this case. The remaining typed getters pass the negative index directly to `TsBlock.getColumn()`, causing `ArrayIndexOutOfBoundsException`.
   
   ### Changes
   
   Add `tsBlockColumnIndex < 0` guards that throw `StatementExecutionException` with a clear message:
   
   | Method | Guard added |
   |--------|------------|
   | `getBooleanByTsBlockColumnIndex` | `"Cannot read boolean from time column"` |
   | `getDoubleByTsBlockColumnIndex` | `"Cannot read double from time column"` |
   | `getFloatByTsBlockColumnIndex` | `"Cannot read float from time column"` |
   | `getIntByTsBlockColumnIndex` | `"Cannot read int32 from time column"` |
   | `getBinaryTsBlockColumnIndex` | `"Cannot read binary from time column"` |
   | `getObjectByTsBlockIndex` | `"Cannot read object from time column"` |
   
   This is consistent with `getLongByTsBlockColumnIndex` which returns the time value for `< 0`, and `getStringByTsBlockColumnIndex` which returns the time value as a string. For non-compatible types, throwing a descriptive exception is preferred over an opaque `ArrayIndexOutOfBoundsException`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Java client time column access throwing ArrayIndexOutOfBoundsException (#17407) [iotdb]

Posted by "PDGGK (via GitHub)" <gi...@apache.org>.
PDGGK commented on PR #17408:
URL: https://github.com/apache/iotdb/pull/17408#issuecomment-4802405161

   Thanks for the suggestion, @HTHou. Separately, I noticed CI was red and it was my change that caused it: making `getObject` reject the time pseudo-column was too aggressive. `getObject` on the time column is a valid, already-tested path (`IoTDBJDBCResultSetTest#testQuery`) and should keep returning the timestamp.
   
   I've restored the time-column branch in the `TIMESTAMP` case of `getObjectByTsBlockIndex` and kept the new `tsBlockColumnIndex < 0` guards only on the strictly-typed getters (boolean/int32/float/double/binary); `getLong`, `getString` and `getObject` continue to read the time column. `IoTDBJDBCResultSetTest` passes locally now.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Java client time column access throwing ArrayIndexOutOfBoundsException (#17407) [iotdb]

Posted by "HTHou (via GitHub)" <gi...@apache.org>.
HTHou commented on PR #17408:
URL: https://github.com/apache/iotdb/pull/17408#issuecomment-4204427301

   Hi, you can subscribe to the development mailing list and mention this PR there. This way, other developers can help you review the PR more quickly.
   
   https://iotdb.apache.org/Community/Communication-Channels.html#_1-mailing-lists


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Java client time column access throwing ArrayIndexOutOfBoundsException (#17407) [iotdb]

Posted by "PDGGK (via GitHub)" <gi...@apache.org>.
PDGGK commented on PR #17408:
URL: https://github.com/apache/iotdb/pull/17408#issuecomment-5156108903

   @HTHou — apologies for sitting on your suggestion for four months; picking it back up now, and taking it properly this time.
   
   **Current status.** The bug is still present on master (`75eaa40`, 2026-07-31) and nothing else has fixed it in the meantime. In `IoTDBRpcDataSet`, `getLongByTsBlockColumnIndex` handles the time pseudo-column (:424) and `getStringByTsBlockColumnIndex` does too (:524), but the five strictly-typed getters — `getBooleanByTsBlockColumnIndex` (:333), `getDoubleByTsBlockColumnIndex` (:353), `getFloatByTsBlockColumnIndex` (:373), `getIntByTsBlockColumnIndex` (:393), `getBinaryTsBlockColumnIndex` (:451) — go straight to `curTsBlock.getColumn(tsBlockColumnIndex)`. Since `isNull(index, rowNum)` is `index >= 0 && ...` (:322), it returns false for the time column and execution enters the value branch with index `-1`. `getDate` inherits it as well, because `getDateByTsBlockColumnIndex` delegates to `getInt` (:599) — six user-visible surfaces, not five. The resulting `ArrayIndexOutOfBoundsException` is unchecked and `IoTDBJDBCResultSet` only catches `StatementExecutionException` (e.g. `ge
 tBoolean` at :349-355), so it escapes through the JDBC API instead of arriving as a `SQLException`. The `Session` `DataIterator` getters pass it through unwrapped too.
   
   **Precedent.** The C++ side of the same asymmetry is already merged as #17400, approved by @jt2594838 on 2026-04-01. Worth being precise about the design, because that PR's description is stale: it originally proposed returning the timestamp cast to `int32`/`float`/`double`/`Binary`, and the throw-everywhere behaviour was imposed in review — @jt2594838 objected to casting on overflow grounds and @CritasWang asked for `IoTDBException` on the numeric getters. This PR is the Java counterpart of that outcome, and I should have said so in the description rather than leaving it to be inferred.
   
   **What's wrong with the PR as it stands, all on me:**
   
   - The five messages are bare string literals. That predates the compile-time i18n work (#17613, #18110); this class now routes every exception message through `RpcMessages`, so these need constants added under both the `en` and `zh` roots in the existing `// IoTDBRpcDataSet / IoTDBJDBCDataSet` section.
   - No test. The C++ twin shipped one, and @jt2594838 asked for it explicitly in that review. `IoTDBJDBCResultSetTest` already builds tree-model TsBlocks in-process, so a unit test asserting that `getInt(1)`/`getFloat(1)`/`getBoolean(1)` surface as `SQLException` while `getLong(1)`/`getString(1)`/`getObject(1)` still return the timestamp is straightforward — no IT needed.
   - CI has never run on the current head: zero workflow runs on that sha, and the last visible signal on this PR is a failed run from 2026-03-31, on a matrix that no longer matches the current one. A rebase and repush should at least create the runs, though they'll sit in `action_required` until someone with write access approves them.
   
   **Plan:** rebase onto master, move the messages into `RpcMessages` (en + zh), add the unit test, verify `mvn test-compile -P with-zh-locale` locally, repush, and rewrite the description to lead with the #17400 review outcome. On the semantics I don't think a list thread is needed: #17400 already settled it — @jt2594838 raised the overflow objection against casting and @CritasWang asked for an `IoTDBException`, so I'll mirror that and ask both of you to confirm on the PR rather than re-open a decided question on the list. I'd also appreciate the pending CI runs being approved when you get a chance, since none have run on the current head.
   
   ---


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Java client time column access throwing ArrayIndexOutOfBoundsException (#17407) [iotdb]

Posted by "PDGGK (via GitHub)" <gi...@apache.org>.
PDGGK commented on PR #17408:
URL: https://github.com/apache/iotdb/pull/17408#issuecomment-5551737641

   Pushed the rework I described on 2026-08-02, rebuilt on current master
   (`219332dacb8`) rather than rebased — the old head no longer shared a merge base
   with master. The description is rewritten. In short: the five messages now go
   through `RpcMessages` in both `en` and `zh` instead of being string literals,
   there is a regression test that fails on unpatched master with `expected a
   SQLException but the time column leaked an unchecked
   java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 3`,
   and the `jdbc` and `service-rpc` suites plus `-P with-zh-locale` are green.
   
   **One correction to what I wrote in August.** I said then that #17400 had already
   settled the semantics and that I would simply mirror it. Re-reading that thread,
   that is not what it says. @CritasWang's comment there was:
   
   > A fast-fail exception … is much safer, and it aligns perfectly with our Java
   > client which typically throws `IndexOutOfBoundsException` or
   > `ClassCastException` for mismatched types on the Time column.
   
   That cites the current Java behaviour as the model for the C++ change — and it
   describes it accurately, since `ArrayIndexOutOfBoundsException` is an
   `IndexOutOfBoundsException`. So #17400 settled the C++ side while treating Java's
   behaviour as fine. Citing it as authority for changing Java gets the reference
   backwards, and I should not have written that.
   
   The argument I would actually make is narrower and does not depend on #17400:
   `java.sql.ResultSet.getInt` declares `throws SQLException`, `IoTDBJDBCResultSet`
   only catches `StatementExecutionException`, so the unchecked exception crosses
   the JDBC boundary and a caller writing `catch (SQLException)` cannot handle it.
   #17400 is then cross-client consistency rather than precedent — same five
   getters, same guard position, and the five message texts verbatim identical to
   the ones merged there. That reframing is a new argument rather than a settled
   conclusion, so it is worth an objection if you disagree with it.
   
   @HTHou — you suggested the dev list back in April as a way to get more review
   attention, and I answered as though you had asked whether the design was settled.
   That was the wrong answer to the question you actually asked, and it is the
   reason I did not follow your suggestion. Since then this branch has had no review
   and no CI at all, so you were right on your own terms. I will post a note to
   `dev@` rather than ask you again.
   
   The push created twelve workflow runs and they are all sitting at
   `conclusion=action_required`. I would appreciate them being approved when someone
   has a moment — there has still been no CI signal on this branch.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Fix Java client time column access throwing ArrayIndexOutOfBoundsException (#17407) [iotdb]

Posted by "JackieTien97 (via GitHub)" <gi...@apache.org>.
JackieTien97 merged PR #17408:
URL: https://github.com/apache/iotdb/pull/17408


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscribe@iotdb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org