googleapis / googleapis/google-http-java-client
NULL_BOOLEAN is not compatible with Value Objects
- 主要言語
- Java
- スター
- 1.4k
- フォーク
- 473
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
`google-http-client` uses sentinel objects like `NULL_BOOLEAN` to distinguish between fields being absent and explicitly set to `null`:
https://github.com/googleapis/google-http-java-client/blame/95fac312dd743a94fb28532ef8a50d374e6481ad/google-http-client/src/main/java/com/google/api/client/util/Data.java#L48-L49
Those sentinel fields are using deprecated constructors like `new Boolean(true)` (the deprecation warnings were suppressed in https://github.com/googleapis/google-http-java-client/pull/1215).
JDK 28 introduces a preview of the value classes feature (https://openjdk.org/jeps/401). With JEP 401 boxed primitive classes like `Boolean` and `Integer` become value classes that don't have identity, so instance are compared by value:
* `new Boolean(true) == Boolean.TRUE` will evaluate to `true`
* `new Integer(0) == Integer.valueOf(0)` will evaluate to `true`
This causes `google-http-client`'s `Data.isNull(object)` to return true for legitimate values.
With JEP 401, assertions like these will start to fail:
```java
assertThat(Data.isNull(true)).isFalse();
assertThat(Data.isNull(0)).isFalse();
assertThat(Data.isNull(0L)).isFalse();
```
Possible fixes:
* Introduce a new API like `JsonNullable` to replace the use of `NULL_BOOLEAN`
* Maintain a set of explicitly set fields, that could be queried instead of relying on sentinel values.
コントリビューションガイド
調査の方向性
Start in google-http-client/src/main/java/com/google/api/client/util/Data.java, especially Data.isNull and NULL_BOOLEAN, and reproduce the assertions shown in the issue with the JDK 28 value-class preview. Compare the two proposed approaches; done means legitimate Boolean, Integer, and Long values no longer return true from Data.isNull while absent and explicit-null tracking remains correct.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- java
- 領域
- api
- issue の種類
- バグ
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 35/100