Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gson.getAdapter((TypeToken) null) throws exception #1831

Closed
Marcono1234 opened this issue Dec 1, 2020 · 0 comments · Fixed by #2153
Closed

Gson.getAdapter((TypeToken) null) throws exception #1831

Marcono1234 opened this issue Dec 1, 2020 · 0 comments · Fixed by #2153

Comments

@Marcono1234
Copy link
Collaborator

The Gson class has logic for handling null arguments for getAdapter(TypeToken), see:

TypeAdapter<?> cached = typeTokenCache.get(type == null ? NULL_KEY_SURROGATE : type);

However, it appears the pull request which tried to keep the support for null arguments also broke it due to commit 31dcfa3 because it does not reassign a non-null value to the type argument anymore which later on in the method causes a NullPointerException.

However that was 4 years ago and it appears support for null arguments might not have been used much (if at all; I did not find existing issues about this here on GitHub). Therefore maybe it would be better instead of fixing this issue to simply remove null handling for getAdapter(TypeToken) completely and to throw an exception on purpose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant