You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.NullPointerException: Cannot invoke "java.lang.reflect.ParameterizedType.getActualTypeArguments()" because the return value of "typetoken.TypeToken.mostSpecializedParameterizedSuperclass(java.lang.reflect.Type)" is null
Given that mostSpecializedParameterizedSuperclass is a private method which is only ever called from the constructor of TypeToken, it isn't a good idea for it to ever return null. If it does ever return null (through misuse of TypeToken), the result will be a generic NPE rather than an specific exception with a helpful error message.
Suggest throwing some flavour of ConfigException rather than returning null. The exception message can be specific to the if block which is throwing it.
Alternatively, if mostSpecializedParameterizedSuperclass can return null, put a null check in the TypeToken constructor and throw the ConfigException from there. However, at this point you will have lost some context about what the (very unexpected) problem is.
If, for some strange reason, you do this...
then you get
Given that mostSpecializedParameterizedSuperclass is a private method which is only ever called from the constructor of TypeToken, it isn't a good idea for it to ever return null. If it does ever return null (through misuse of TypeToken), the result will be a generic NPE rather than an specific exception with a helpful error message.
Suggest throwing some flavour of ConfigException rather than returning null. The exception message can be specific to the if block which is throwing it.
Alternatively, if mostSpecializedParameterizedSuperclass can return null, put a null check in the TypeToken constructor and throw the ConfigException from there. However, at this point you will have lost some context about what the (very unexpected) problem is.
Credit to @Azquelt for spotting this issue.
The text was updated successfully, but these errors were encountered: