apache / apache/iotdb

[Bug] ResultSetMetaData.getCatalogName throws IndexOutOfBoundsException instead of SQLException for out-of-range columns

オープン 初心者向け
#18,241 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Java
スター
6.4k
フォーク
1.2k
平均マージ
1日 23時間
マージ済み PR(30日)
115

説明

### Search before asking

- [x] I searched in the [issues](https://github.com/apache/iotdb/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:

1. Obtain a `ResultSetMetaData` from any (non-empty) query result.
2. Call `metaData.getCatalogName(0)` (or any column index `<= 0` or `> column count`).
3. A raw `IndexOutOfBoundsException` is thrown instead of a `SQLException`.

### 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?

- [x] I'm willing to submit a PR!

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

IoTDBResultMetadata.getCatalogName(int) を含むクラスから始め、最初に checkColumnIndex(column) を呼び出す、対応する7つの ResultSetMetaData アクセサと比較します。getCatalogName(0) または範囲外の別の列を使って問題を再現し、その後、無効なインデックスが一貫して IndexOutOfBoundsException ではなく SQLException を生成することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
java
領域
databases
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
78/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。