22
33import dev .openfeature .sdk .EvaluationContext ;
44import dev .openfeature .sdk .ImmutableContext ;
5- import dev .openfeature .sdk .ImmutableStructure ;
65import dev .openfeature .sdk .ProviderEvent ;
7- import dev .openfeature .sdk .Structure ;
86import dev .openfeature .sdk .exceptions .GeneralError ;
97import lombok .Getter ;
108import lombok .Setter ;
11- import lombok .extern .slf4j .Slf4j ;
129
1310/**
1411 * Contains all fields we need to worry about locking, used as intrinsic lock
1512 * for sync blocks in the {@link FlagdProvider}.
1613 */
17- @ Slf4j
1814@ Getter
1915class FlagdProviderSyncResources {
2016 @ Setter
2117 private volatile ProviderEvent previousEvent = null ;
2218
23- private volatile ImmutableStructure syncMetadata = new ImmutableStructure ();
2419 private volatile EvaluationContext enrichedContext = new ImmutableContext ();
2520 private volatile boolean initialized ;
2621 private volatile boolean isShutDown ;
2722
28- public void setSyncMetadata (Structure syncMetadata ) {
29- this .syncMetadata = new ImmutableStructure (syncMetadata .asMap ());
30- }
31-
3223 public void setEnrichedContext (EvaluationContext context ) {
3324 this .enrichedContext = new ImmutableContext (context .asMap ());
3425 }
@@ -40,14 +31,11 @@ public void setEnrichedContext(EvaluationContext context) {
4031 * @return true iff this was the first call to {@code initialize()}
4132 */
4233 public synchronized boolean initialize () {
43- log .info ("initialize in wait" );
4434 if (this .initialized ) {
4535 return false ;
4636 }
4737 this .initialized = true ;
4838 this .notifyAll ();
49- log .info ("notified all " + this .toString ());
50-
5139 return true ;
5240 }
5341
@@ -66,7 +54,6 @@ public synchronized boolean initialize() {
6654 * this object
6755 */
6856 public void waitForInitialization (long deadline ) {
69- log .info ("wait for init " + this );
7057 long start = System .currentTimeMillis ();
7158 long end = start + deadline ;
7259 while (!initialized && !isShutDown ) {
@@ -78,34 +65,29 @@ public void waitForInitialization(long deadline) {
7865 }
7966 long remaining = end - now ;
8067 synchronized (this ) {
81- if (initialized ) { // might have changed in the meantime
82- log .info ("post wait for init in loop" );
83- return ;
84- }
8568 if (isShutDown ) {
8669 break ;
8770 }
88- log .info ("waiting for " + remaining + " at " + System .currentTimeMillis ());
71+ if (initialized ) { // might have changed in the meantime
72+ return ;
73+ }
8974 try {
9075 this .wait (remaining );
9176 } catch (InterruptedException e ) {
9277 // try again. Leave the continue to make PMD happy
9378 continue ;
9479 }
95- log .info ("waiting ended at " + System .currentTimeMillis ());
9680 }
9781 }
9882 if (isShutDown ) {
9983 throw new IllegalStateException ("Already shut down" );
10084 }
101- log .info ("post wait for init" );
10285 }
10386
10487 /**
10588 * Signals a shutdown. Threads waiting for initialization will wake up and throw an {@link IllegalStateException}.
10689 */
10790 public synchronized void shutdown () {
108- log .info ("shutdown in wait" );
10991 isShutDown = true ;
11092 this .notifyAll ();
11193 }
0 commit comments