NULL_BOOLEAN is not compatible with Value Objects
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
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.
Written by the indexing model from the issue text.
Description
google-http-client uses sentinel objects like NULL_BOOLEAN to distinguish between fields being absent and explicitly set to null:
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.TRUEwill evaluate totruenew Integer(0) == Integer.valueOf(0)will evaluate totrue
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:
assertThat(Data.isNull(true)).isFalse();
assertThat(Data.isNull(0)).isFalse();
assertThat(Data.isNull(0L)).isFalse();
Possible fixes:
- Introduce a new API like
JsonNullable<Boolean>to replace the use ofNULL_BOOLEAN - Maintain a set of explicitly set fields, that could be queried instead of relying on sentinel values.
- Dominant language
- Java
- Stars
- 1.4k
- Forks
- 476
- Avg merge
- 10h 47m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing 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 googleapis/google-http-java-client
-
Core: Validate header names and values to prevent CRLF injectionPossibly taken @insaf021 claimed this 106 days ago. Openpriority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Core: XmlPullParser processes external DTD entities (XXE) — disable FEATURE_PROCESS_DOCDECL in Xml#createParser()Possibly taken @insaf021 claimed this 106 days ago. Openpriority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Core: LowLevelHttpResponse not disconnected when HttpResponse construction throws RuntimeExceptionPossibly taken @insaf021 claimed this 106 days ago. Openpriority: p3
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
type: cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
org.apache.http.conn.ssl.SSLSocketFactory is deprecatedMay be free again A pull request for this issue was closed without being merged. Openpriority: p2 type: cleanup
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
All issues in googleapis/google-http-java-client
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
-
Difficulty 2/5 Under an hour Newbie friendliness 84/100
cpp-best-practices/project_validator#251 ·
Maintainers usually reply within 1 day
-
backend enhancement
Difficulty 2/5 Half a day Newbie friendliness 70/100
damodharg6/payledger#16 ·
-
[Bug]: An initiative list with no current entry logs an error on every changePossibly taken @dwizard0 claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
Maintainers usually reply within 1 day