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
The method Token.fromString(@Nullable String) throws a NullPointer when passing a null String into the method. This is missleading for a couple of reasons
The method is annotated with @Nullable so it would seem it acceptable to pass a null object into it. It seems that this annotation should be @NotNull
The stack trace lead me to looking into the internals of JSONTokener which is were the error originates from. Rather than giving a reasonable stacktrace and message so developers can diagnose the issue. A exception could be thrown with a message such "A null string cannot be converted to a token" if a null string is passed into the method.
java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2673)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2734)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1485)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6195)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference
at org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116)
at org.json.JSONTokener.nextValue(JSONTokener.java:94)
at org.json.JSONObject.<init>(JSONObject.java:156)
at org.json.JSONObject.<init>(JSONObject.java:173)
at com.stripe.android.model.Token.fromString(Token.java:160) ```
The text was updated successfully, but these errors were encountered:
Hi @sdoward! Thanks so much for bringing this our attention :) Sorry about your time spend debugging. I've put a PR to handle null there the same way the other methods in the class handle null.
The method
Token.fromString(@Nullable String)
throws a NullPointer when passing a null String into the method. This is missleading for a couple of reasons@Nullable
so it would seem it acceptable to pass a null object into it. It seems that this annotation should be@NotNull
JSONTokener
which is were the error originates from. Rather than giving a reasonable stacktrace and message so developers can diagnose the issue. A exception could be thrown with a message such "A null string cannot be converted to a token" if a null string is passed into the method.The text was updated successfully, but these errors were encountered: