From 9d8678efcacab097515ef78258486a5ed9f35c54 Mon Sep 17 00:00:00 2001 From: tobias Date: Tue, 10 Dec 2019 11:40:12 +0100 Subject: [PATCH 1/4] - remove blocking. Using synchronized block allows only one thread at a time - so every other thread will need to wait. --- Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java index 3f39c2741..f384f2a11 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java @@ -17,7 +17,7 @@ public class Adjust { /** * Singleton Adjust SDK instance. */ - private static AdjustInstance defaultInstance; + private static AdjustInstance defaultInstance = new AdjustIntance(); /** * Private constructor. @@ -30,13 +30,10 @@ private Adjust() { * * @return Adjust SDK singleton instance. */ - public static synchronized AdjustInstance getDefaultInstance() { + public static AdjustInstance getDefaultInstance() { @SuppressWarnings("unused") String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.19.0"; - if (defaultInstance == null) { - defaultInstance = new AdjustInstance(); - } return defaultInstance; } From 1eabd3fa4cd6148802c0a5049e0a92c8475fa000 Mon Sep 17 00:00:00 2001 From: tobias Date: Tue, 10 Dec 2019 11:41:37 +0100 Subject: [PATCH 2/4] - remove blocking. Using synchronized block allows only one thread at a time - so every other thread will need to wait. --- Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java index f384f2a11..bb7f4d26c 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java @@ -15,7 +15,7 @@ */ public class Adjust { /** - * Singleton Adjust SDK instance. + * eagerly create singleton Adjust SDK instance immediately when the class is loaded or initialized by Android ClassLoader */ private static AdjustInstance defaultInstance = new AdjustIntance(); From 1acc318af0f0516634ecfee1d4fe589bee5d2109 Mon Sep 17 00:00:00 2001 From: tobias Date: Tue, 10 Dec 2019 11:43:50 +0100 Subject: [PATCH 3/4] - remove blocking. Using synchronized block allows only one thread at a time - so every other thread will need to wait - increased version to 4.19.1 --- CHANGELOG.md | 5 +++++ VERSION | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2d83576e..e1f866606 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +### Version 4.19.1 (10th December 2019) +#### Added +- removed locking from singleton instance creation + + ### Version 4.19.0 (9th December 2019) #### Added - Added `disableThirdPartySharing(Context)` method to `Adjust` interface to allow disabling of data sharing with third parties outside of Adjust ecosystem. diff --git a/VERSION b/VERSION index a69aa5a42..1fc0e81ec 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.19.0 +4.19.1 From ee68ed8ed1cff7bfffa09ab18f64eb8a4d19a048 Mon Sep 17 00:00:00 2001 From: tobias Date: Fri, 13 Dec 2019 08:24:47 +0100 Subject: [PATCH 4/4] - reduced blocking. Using synchronized block allows only one thread at a time - so every other thread will need to wait - increased version to 4.19.1 --- .../sdk-core/src/main/java/com/adjust/sdk/Adjust.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java index bb7f4d26c..3c189ae77 100644 --- a/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java +++ b/Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java @@ -17,8 +17,7 @@ public class Adjust { /** * eagerly create singleton Adjust SDK instance immediately when the class is loaded or initialized by Android ClassLoader */ - private static AdjustInstance defaultInstance = new AdjustIntance(); - + private volatile AdjustInstance defaultInstance; /** * Private constructor. */ @@ -34,6 +33,13 @@ public static AdjustInstance getDefaultInstance() { @SuppressWarnings("unused") String VERSION = "!SDK-VERSION-STRING!:com.adjust.sdk:adjust-android:4.19.0"; + if (defaultInstance == null) { + synchronized (Adjust.class) { + if (defaultInstance == null) { + defaultInstance = new AdjustInstance(); + } + } + } return defaultInstance; }