[Bug] ResultSetMetaData.getCatalogName throws IndexOutOfBoundsException instead of SQLException for out-of-range columns
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in the class containing IoTDBResultMetadata.getCatalogName(int) and compare it with the seven sibling ResultSetMetaData accessors that call checkColumnIndex(column) first. Reproduce the issue with getCatalogName(0) or another out-of-range column, then verify that invalid indexes consistently produce SQLException rather than IndexOutOfBoundsException.
Written by the indexing model from the issue text.
Description
Search before asking
- I searched in the issues and found nothing similar.
Version
master (2.0.x). The affected code is also present in released 2.0.x versions.
Describe the bug and provide the minimal reproduce step
IoTDBResultMetadata.getCatalogName(int column) reads columnInfoList.get(column - 1) before its range check runs, so an out-of-range column index throws a raw IndexOutOfBoundsException instead of the SQLException required by the ResultSetMetaData contract. The subsequent range check (if (column < 1 || column > columnInfoList.size())) is therefore unreachable for an out-of-range column. The seven sibling ResultSetMetaData accessors in the same class all call checkColumnIndex(column) first; getCatalogName is the only one missing that guard.
Minimal reproduce step:
- Obtain a
ResultSetMetaDatafrom any (non-empty) query result. - Call
metaData.getCatalogName(0)(or any column index<= 0or> column count). - A raw
IndexOutOfBoundsExceptionis thrown instead of aSQLException.
What did you expect to see?
getCatalogName throws a SQLException for an out-of-range column index, consistent with the ResultSetMetaData contract and with the sibling accessors.
What did you see instead?
A raw java.lang.IndexOutOfBoundsException from columnInfoList.get(column - 1).
Anything else?
The fix is to call checkColumnIndex(column) first, as the sibling accessors already do — it throws SQLException on column <= 0, column > size, and an empty column list. I'd like to work on this and will open a PR.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Dominant language
- Java
- Stars
- 6.4k
- Forks
- 1.2k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 129
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/iotdb
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
IoTDB Edge: stop-edge.sh does not stop its own process when IOTDB_HOME is set, and reports success Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column name Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
elastic/gradle-plugins#157 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
cryptomator/hub#497 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
johanhaleby/occurrent#1120 ·