jenkins-bot has submitted this change and it was merged.

Change subject: Fix possible crash due to null CookieManager.

Fix possible crash due to null CookieManager.

Although I've been unable to reproduce it, I'm fairly sure about the cause
of this crash:

Inside OkHttpConnectionFactory, we initialize the CLIENT statically.
However, the instance of the client depends on the cookieManager to be
initialized in WikipediaApp, *but* the initialization of the cookieManager
only happens in onCreate(). This leaves open a possibility of CLIENT to be
initialized while cookieManager is still null.

This patch switches to initializing the CLIENT lazily, ensuring that the
cookieManager will have been initialized prior to any access of the

Bug: T148172
Change-Id: Ieb16b0f4b9ea85eeabfb6923417f9bc3d9a85b94
M app/src/main/java/org/wikipedia/
1 file changed, 4 insertions(+), 1 deletion(-)

  Mholloway: Looks good to me, approved
  jenkins-bot: Verified

diff --git a/app/src/main/java/org/wikipedia/ 
index 8c363f0..a6f0521 100644
--- a/app/src/main/java/org/wikipedia/
+++ b/app/src/main/java/org/wikipedia/
@@ -24,7 +24,7 @@
 public class OkHttpConnectionFactory implements HttpRequest.ConnectionFactory {
     private static final long HTTP_CACHE_SIZE = 64 * 1024 * 1024;
     private static final Cache HTTP_CACHE = new 
Cache(WikipediaApp.getInstance().getCacheDir(), HTTP_CACHE_SIZE);
-    @NonNull private static final OkHttpClient CLIENT = createClient();
+    private static OkHttpClient CLIENT;
     public HttpURLConnection create(URL url) throws IOException {
@@ -39,6 +39,9 @@
     public static OkHttpClient getClient() {
+        if (CLIENT == null) {
+            CLIENT = createClient();
+        }
         return CLIENT;

To view, visit
To unsubscribe, visit

Gerrit-MessageType: merged
Gerrit-Change-Id: Ieb16b0f4b9ea85eeabfb6923417f9bc3d9a85b94
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <>
Gerrit-Reviewer: BearND <>
Gerrit-Reviewer: Brion VIBBER <>
Gerrit-Reviewer: Mholloway <>
Gerrit-Reviewer: Niedzielski <>
Gerrit-Reviewer: jenkins-bot <>

MediaWiki-commits mailing list

Reply via email to