@@ -18,14 +18,14 @@ class Statsig {
18
18
serverSecret : String ,
19
19
options : StatsigOptions ,
20
20
) {
21
- if (! ::statsigServer. isInitialized) { // Quick check without synchronization
21
+ if (! isInitialized() ) { // Quick check without synchronization
22
22
synchronized(this ) {
23
- if (! ::statsigServer. isInitialized
23
+ if (! isInitialized()
24
24
) { // Secondary check in case another thread already created the default server
25
- statsigServer = StatsigServer .create(serverSecret, options )
25
+ statsigServer = StatsigServer .create()
26
26
}
27
27
}
28
- statsigServer.initialize()
28
+ statsigServer.initialize(serverSecret, options )
29
29
}
30
30
}
31
31
@@ -241,7 +241,7 @@ class Statsig {
241
241
/* *
242
242
* Sets a value to be returned for the given dynamic config/experiment instead of the actual evaluated value.
243
243
*
244
- * @param configName The name of the dynamic config or experiment to be overriden
244
+ * @param configName The name of the dynamic config or experiment to be overridden
245
245
* @param configValue The value that will be returned
246
246
*/
247
247
@JvmStatic
@@ -359,14 +359,14 @@ class Statsig {
359
359
serverSecret : String ,
360
360
options : StatsigOptions = StatsigOptions (),
361
361
): CompletableFuture <Void ?> {
362
- if (! ::statsigServer. isInitialized) { // Quick check without synchronization
362
+ if (! isInitialized() ) { // Quick check without synchronization
363
363
synchronized(this ) {
364
- if (! ::statsigServer. isInitialized
364
+ if (! isInitialized()
365
365
) { // Secondary check in case another thread already created the default server
366
- statsigServer = StatsigServer .create(serverSecret, options )
366
+ statsigServer = StatsigServer .create()
367
367
}
368
368
}
369
- return statsigServer.initializeAsync()
369
+ return statsigServer.initializeAsync(serverSecret, options )
370
370
}
371
371
return CompletableFuture .completedFuture(null )
372
372
}
@@ -631,12 +631,17 @@ class Statsig {
631
631
runBlocking { statsigServer.shutdown() }
632
632
}
633
633
634
+ @JvmStatic
635
+ fun isInitialized (): Boolean {
636
+ return ::statsigServer.isInitialized && statsigServer.initialized
637
+ }
638
+
634
639
private fun checkInitialized (): Boolean {
635
- if (! ::statsigServer.isInitialized) {
640
+ val initialized = isInitialized()
641
+ if (! initialized) {
636
642
println (" Call and wait for initialize to complete before calling SDK methods." )
637
- return false
638
643
}
639
- return true
644
+ return initialized
640
645
}
641
646
}
642
647
}
0 commit comments