fix race condition leading to NPE

This commit is contained in:
Eric House 2019-06-03 20:40:49 -07:00
parent 4f63ad3b83
commit 5bce759d32

View file

@ -1521,8 +1521,9 @@ public class DBUtils {
// Map of groups rowid (= summaries.groupid) to group info record // Map of groups rowid (= summaries.groupid) to group info record
protected static Map<Long,GameGroupInfo> getGroups( Context context ) protected static Map<Long,GameGroupInfo> getGroups( Context context )
{ {
if ( null == s_groupsCache ) { Map<Long,GameGroupInfo> result = s_groupsCache;
Map<Long,GameGroupInfo> result = new HashMap<>(); if ( null == result ) {
result = new HashMap<>();
// Select all groups. For each group get the number of games in // 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 // that group. There should be a way to do that with one query
@ -1561,8 +1562,8 @@ public class DBUtils {
} }
s_groupsCache = result; s_groupsCache = result;
} }
Log.d( TAG, "getGroups() => %s", s_groupsCache ); Log.d( TAG, "getGroups() => %s", result );
return s_groupsCache; return result;
} // getGroups } // getGroups
private static void readTurnInfo( SQLiteDatabase db, long groupID, private static void readTurnInfo( SQLiteDatabase db, long groupID,