From 5bce759d3277c9ded22cfa8a9a304d7472a46726 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 3 Jun 2019 20:40:49 -0700 Subject: [PATCH] fix race condition leading to NPE --- .../src/main/java/org/eehouse/android/xw4/DBUtils.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java index 83a6d3a5e..5997f73a5 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/DBUtils.java @@ -1521,8 +1521,9 @@ public class DBUtils { // Map of groups rowid (= summaries.groupid) to group info record protected static Map getGroups( Context context ) { - if ( null == s_groupsCache ) { - Map result = new HashMap<>(); + Map result = s_groupsCache; + if ( null == result ) { + result = new HashMap<>(); // Select all groups. For each group get the number of games in // that group. There should be a way to do that with one query @@ -1561,8 +1562,8 @@ public class DBUtils { } s_groupsCache = result; } - Log.d( TAG, "getGroups() => %s", s_groupsCache ); - return s_groupsCache; + Log.d( TAG, "getGroups() => %s", result ); + return result; } // getGroups private static void readTurnInfo( SQLiteDatabase db, long groupID,