[libbluray-devel] Fix race condition in multiple getInstance() functions

hpi1 git at videolan.org
Fri May 22 11:13:26 CEST 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Fri May 22 11:53:09 2015 +0300| [4916e820911da709a5b0e0c33aeecdefb208af32] | committer: hpi1

Fix race condition in multiple getInstance() functions

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=4916e820911da709a5b0e0c33aeecdefb208af32
---

 src/libbluray/bdj/java/org/bluray/bdplus/Status.java           |    2 +-
 src/libbluray/bdj/java/org/bluray/storage/StorageManager.java  |    2 +-
 src/libbluray/bdj/java/org/dvb/event/EventManager.java         |    2 +-
 src/libbluray/bdj/java/org/dvb/user/UserPreferenceManager.java |    2 +-
 src/libbluray/bdj/java/org/videolan/BDJAppsDatabase.java       |    4 ++--
 5 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/libbluray/bdj/java/org/bluray/bdplus/Status.java b/src/libbluray/bdj/java/org/bluray/bdplus/Status.java
index 3f5fcf6..b897b3e 100644
--- a/src/libbluray/bdj/java/org/bluray/bdplus/Status.java
+++ b/src/libbluray/bdj/java/org/bluray/bdplus/Status.java
@@ -28,8 +28,8 @@ public class Status {
         synchronized (Status.class) {
             if (instance == null)
                 instance = new Status();
+            return instance;
         }
-        return instance;
     }
 
     public static void shutdown() {
diff --git a/src/libbluray/bdj/java/org/bluray/storage/StorageManager.java b/src/libbluray/bdj/java/org/bluray/storage/StorageManager.java
index 961c8ec..5ea1c57 100644
--- a/src/libbluray/bdj/java/org/bluray/storage/StorageManager.java
+++ b/src/libbluray/bdj/java/org/bluray/storage/StorageManager.java
@@ -24,8 +24,8 @@ public class StorageManager {
         synchronized (StorageManager.class) {
             if (instance == null)
                 instance = new StorageManager();
+            return instance;
         }
-        return instance;
     }
 
     protected StorageManager() {
diff --git a/src/libbluray/bdj/java/org/dvb/event/EventManager.java b/src/libbluray/bdj/java/org/dvb/event/EventManager.java
index 2bf2ea4..029cc26 100644
--- a/src/libbluray/bdj/java/org/dvb/event/EventManager.java
+++ b/src/libbluray/bdj/java/org/dvb/event/EventManager.java
@@ -40,8 +40,8 @@ public class EventManager implements ResourceServer {
         synchronized (EventManager.class) {
             if (instance == null)
                 instance = new EventManager();
+            return instance;
         }
-        return instance;
     }
 
     public static void shutdown() {
diff --git a/src/libbluray/bdj/java/org/dvb/user/UserPreferenceManager.java b/src/libbluray/bdj/java/org/dvb/user/UserPreferenceManager.java
index 239c966..af86b4e 100644
--- a/src/libbluray/bdj/java/org/dvb/user/UserPreferenceManager.java
+++ b/src/libbluray/bdj/java/org/dvb/user/UserPreferenceManager.java
@@ -31,8 +31,8 @@ public class UserPreferenceManager {
         synchronized (UserPreferenceManager.class) {
             if (instance == null)
                 instance = new UserPreferenceManager();
+            return instance;
         }
-        return instance;
     }
 
     public void read(Preference p) {
diff --git a/src/libbluray/bdj/java/org/videolan/BDJAppsDatabase.java b/src/libbluray/bdj/java/org/videolan/BDJAppsDatabase.java
index 13c088f..ca39f12 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJAppsDatabase.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJAppsDatabase.java
@@ -35,8 +35,8 @@ public class BDJAppsDatabase extends AppsDatabase {
         synchronized (BDJAppsDatabase.class) {
             if (instance == null)
                 instance = new BDJAppsDatabase();
+            return instance;
         }
-        return instance;
     }
 
     public int size() {
@@ -106,5 +106,5 @@ public class BDJAppsDatabase extends AppsDatabase {
     private BDJAppProxy[] appProxys = null;
     private AppEntry[] appTable = null;
 
-    protected static BDJAppsDatabase instance = null;
+    private static BDJAppsDatabase instance = null;
 }



More information about the libbluray-devel mailing list