Skip to content

Fix Java client time column access throwing ArrayIndexOutOfBoundsException (#17407)#17408

Open
PDGGK wants to merge 1 commit intoapache:masterfrom
PDGGK:fix/java-client-time-column-guard
Open

Fix Java client time column access throwing ArrayIndexOutOfBoundsException (#17407)#17408
PDGGK wants to merge 1 commit intoapache:masterfrom
PDGGK:fix/java-client-time-column-guard

Conversation

@PDGGK
Copy link
Copy Markdown
Contributor

@PDGGK PDGGK commented Mar 31, 2026

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.

…ption (apache#17407)

Add tsBlockColumnIndex < 0 guards to all ByTsBlockColumnIndex getter
methods that were missing them. When the time pseudo-column is accessed
through a typed getter other than getLong or getString, throw
StatementExecutionException instead of causing ArrayIndexOutOfBoundsException
from TsBlock.getColumn(-1).

Signed-off-by: Zihan Dai <1436286758@qq.com>
@PDGGK PDGGK force-pushed the fix/java-client-time-column-guard branch from 4cbf842 to 5d080cb Compare March 31, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Java client time column access throwing ArrayIndexOutOfBoundsException for non-long typed getters

1 participant