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.
The
Gsonclass has logic for handlingnullarguments forgetAdapter(TypeToken), see:gson/gson/src/main/java/com/google/gson/Gson.java
Line 434 in ceae88b
However, it appears the pull request which tried to keep the support for
nullarguments also broke it due to commit 31dcfa3 because it does not reassign a non-nullvalue to thetypeargument anymore which later on in the method causes aNullPointerException.However that was 4 years ago and it appears support for
nullarguments 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 removenullhandling forgetAdapter(TypeToken)completely and to throw an exception on purpose.