apache / apache/iotdb

[Bug] findColumn throws NullPointerException instead of SQLException for an unknown column name

オープン 初心者向け
#18,250 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Java
スター
6.4k
フォーク
1.2k
平均マージ
1日 23時間
マージ済み PR(30日)
115

説明

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

IoTDBRpcDataSet.findColumn(String) returns columnOrdinalMap.get(columnName) directly. When the column name is not present, Map<String, Integer>.get returns null, which auto-unboxes to int and throws a NullPointerException. The JDBC contract (ResultSet.findColumn) requires a SQLException when the column is not found, and the sibling findColumnNameByIndex already guards its input and throws — the guard was simply omitted for findColumn.

This surfaces at the JDBC boundary (IoTDBJDBCResultSet.findColumn) and through SessionDataSet.DataIterator.findColumn, both of which delegate to the method above. The same missing guard also exists in IoTDBJDBCDataSet.findColumn.

Minimal reproduce step:

  1. Execute any query over JDBC and obtain the ResultSet.
  2. Call resultSet.findColumn("a_column_name_that_is_not_in_the_result").
  3. A raw NullPointerException is thrown instead of a SQLException.
What did you expect to see?

findColumn throws a SQLException (at the JDBC boundary) that names the missing column, per the ResultSet.findColumn contract.

What did you see instead?

A NullPointerException, from unboxing the null returned by the column-ordinal map lookup.

Anything else?

The fix mirrors the existing findColumnNameByIndex guard: throw a checked StatementExecutionException at the rpc layer (reusing the existing UNKNOWN_COLUMN_NAME message), converted to SQLException at the JDBC boundary. I'd like to work on this and will open a PR (which also fixes the identical, currently-unused-but-public IoTDBJDBCDataSet.findColumn).

Are you willing to submit a PR?
  • I'm willing to submit a PR!

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

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

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

IoTDBRpcDataSet.findColumn から開始し、既存の findColumnNameByIndex の guard と比較してから、IoTDBJDBCResultSet.findColumn と SessionDataSet.DataIterator.findColumn を通じて JDBC 境界をたどります。IoTDBJDBCDataSet.findColumn も確認してください。未知のカラムに対して NullPointerException ではなく、見つからないカラム名を示す SQLException が発生すれば完了です。

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

評価

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

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

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