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..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 @@ -15,10 +15,9 @@ */ 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; - + private volatile AdjustInstance defaultInstance; /** * Private constructor. */ @@ -30,12 +29,16 @@ 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(); + synchronized (Adjust.class) { + if (defaultInstance == null) { + defaultInstance = new AdjustInstance(); + } + } } return defaultInstance; } 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