From 00b2ea57510c4df656b63d14535b5fcbcd7efd32 Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Thu, 26 Dec 2013 09:25:13 +0100 Subject: findbugs: synchronize lazy initialized objects --- main/src/cgeo/geocaching/DataStore.java | 2 +- main/src/cgeo/geocaching/maps/CGeoMap.java | 5 +---- main/src/cgeo/geocaching/settings/Settings.java | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/main/src/cgeo/geocaching/DataStore.java b/main/src/cgeo/geocaching/DataStore.java index 9075d45..c6ee9f2 100644 --- a/main/src/cgeo/geocaching/DataStore.java +++ b/main/src/cgeo/geocaching/DataStore.java @@ -304,7 +304,7 @@ public class DataStore { } } - public static void closeDb() { + public static synchronized void closeDb() { if (database == null) { return; } diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 927ff28..d8cad51 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -186,7 +186,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto private boolean markersInvalidated = false; // previous state for loadTimer private boolean centered = false; // if map is already centered private boolean alreadyCentered = false; // -""- for setting my location - private static Set dirtyCaches = null; + private static final Set dirtyCaches = new HashSet(); // Thread pooling private static BlockingQueue displayQueue = new ArrayBlockingQueue(1); @@ -1605,9 +1605,6 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } public static void markCacheAsDirty(final String geocode) { - if (dirtyCaches == null) { - dirtyCaches = new HashSet(); - } dirtyCaches.add(geocode); } diff --git a/main/src/cgeo/geocaching/settings/Settings.java b/main/src/cgeo/geocaching/settings/Settings.java index 186e5d9..0732866 100644 --- a/main/src/cgeo/geocaching/settings/Settings.java +++ b/main/src/cgeo/geocaching/settings/Settings.java @@ -599,7 +599,7 @@ public class Settings { putInt(R.string.pref_lastmaplon, mapViewCenter.getLongitudeE6()); } - public static MapSource getMapSource() { + public static synchronized MapSource getMapSource() { if (mapSource != null) { return mapSource; } -- cgit v1.1