App crashes when clientId is not set
Hi,
we have an app that works just fine with the current parse android version 1.13.1.
When adding the dependency for ParseLiveQuery version 1.0.3 the app won't start any more because of a null pointer crash in okhttp3:
W/System.err: com.parse.ParseException: java.lang.NullPointerException: value == null
W/System.err: at com.parse.ParseTaskUtils$2$1.run(ParseTaskUtils.java:114)
W/System.err: at android.os.Handler.handleCallback(Handler.java:739)
W/System.err: at android.os.Handler.dispatchMessage(Handler.java:95)
W/System.err: at android.os.Looper.loop(Looper.java:148)
W/System.err: at android.app.ActivityThread.main(ActivityThread.java:5417)
W/System.err: at java.lang.reflect.Method.invoke(Native Method)
W/System.err: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
W/System.err: Caused by: java.lang.NullPointerException: value == null
W/System.err: at okhttp3.Headers$Builder.checkNameAndValue(Headers.java:316)
W/System.err: at okhttp3.Headers$Builder.add(Headers.java:270)
W/System.err: at com.parse.ParseOkHttpClient.getRequest(ParseOkHttpClient.java:138)
W/System.err: at com.parse.ParseOkHttpClient.executeInternal(ParseOkHttpClient.java:64)
W/System.err: at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:158)
W/System.err: at com.parse.ParsePlugins$1.intercept(ParsePlugins.java:115)
W/System.err: at com.parse.ParseHttpClient$ParseNetworkInterceptorChain.proceed(ParseHttpClient.java:147)
W/System.err: at com.parse.ParseHttpClient.execute(ParseHttpClient.java:122)
W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:136)
W/System.err: at com.parse.ParseRequest$3.then(ParseRequest.java:133)
W/System.err: at bolts.Task$15.run(Task.java:917)
W/System.err: at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:105)
W/System.err: at bolts.Task.completeAfterTask(Task.java:908)
W/System.err: at bolts.Task.continueWithTask(Task.java:715)
W/System.err: at bolts.Task.continueWithTask(Task.java:726)
W/System.err: at bolts.Task$13.then(Task.java:818)
W/System.err: at bolts.Task$13.then(Task.java:806)
W/System.err: at bolts.Task$15.run(Task.java:917)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
W/System.err: at java.lang.Thread.run(Thread.java:818)
I investigated the issue. The NPE is thrown because our server and client does not set a clientId (which is optional with the new parse-server according to the guide). Thus, X-Parse-Client-Key is null which is actually logged in the working version:
W/System: Ignoring header X-Parse-Client-Key because its value was null.
I did not use any functionality of ParseLiveQuery. Still, ParseLiveQuery depends on okhttp3 version 3.4.0 while Parse-Android-SDK depends on okhttp3 version 3.3.1. Gradle seems to prefer the higher version which shows the mentioned behavior. okhttp3's changelog also describes a major change in HttpURLConnection in version 3.4.0.
Maybe, for now ParseLiveQuery could just downgrade okhttp3 to version 3.3.1?
Actually one quick fix for now is to just set the clientId on the android client side to an empty string.