8
8
import dev .openfeature .sdk .exceptions .GeneralError ;
9
9
import lombok .Getter ;
10
10
import lombok .Setter ;
11
+ import lombok .extern .slf4j .Slf4j ;
11
12
12
13
/**
13
14
* Contains all fields we need to worry about locking, used as intrinsic lock
14
15
* for sync blocks in the {@link FlagdProvider}.
15
16
*/
17
+ @ Slf4j
16
18
@ Getter
17
19
class FlagdProviderSyncResources {
18
20
@ Setter
@@ -38,6 +40,7 @@ public void setEnrichedContext(EvaluationContext context) {
38
40
* @return true iff this was the first call to {@code initialize()}
39
41
*/
40
42
public synchronized boolean initialize () {
43
+ log .info ("initialize in wait" );
41
44
if (this .initialized ) {
42
45
return false ;
43
46
}
@@ -47,20 +50,21 @@ public synchronized boolean initialize() {
47
50
}
48
51
49
52
/**
50
- * Blocks the calling thread until either {@link EventsLock #initialize()} or {@link EventsLock#shutdown()} is called
51
- * or the deadline is exceeded, whatever happens first. If {@link EventsLock#initialize()} has been executed before
52
- * {@code waitForInitialization(long )} is called, it will return instantly.
53
- * If the deadline is exceeded, a GeneralError will be thrown.
54
- * If {@link EventsLock #shutdown()} is called in the meantime, an {@link IllegalStateException} will be thrown.
55
- * Otherwise, the method will return cleanly.
53
+ * Blocks the calling thread until either {@link FlagdProviderSyncResources #initialize()} or
54
+ * {@link FlagdProviderSyncResources#shutdown()} is called or the deadline is exceeded, whatever happens first. If
55
+ * {@link FlagdProviderSyncResources#initialize( )} has been executed before {@code waitForInitialization(long)} is
56
+ * called, it will return instantly. If the deadline is exceeded, a GeneralError will be thrown.
57
+ * If {@link FlagdProviderSyncResources #shutdown()} is called in the meantime, an {@link IllegalStateException} will
58
+ * be thrown. Otherwise, the method will return cleanly.
56
59
*
57
60
* @param deadline the maximum time in ms to wait
58
- * @throws GeneralError when the deadline is exceeded before {@link EventsLock#initialize()} is called on
59
- * this
60
- * object
61
- * @throws IllegalStateException when {@link EventsLock#shutdown()} is called or has been called on this object
61
+ * @throws GeneralError when the deadline is exceeded before
62
+ * {@link FlagdProviderSyncResources#initialize()} is called on this object
63
+ * @throws IllegalStateException when {@link FlagdProviderSyncResources#shutdown()} is called or has been called on
64
+ * this object
62
65
*/
63
66
public void waitForInitialization (long deadline ) {
67
+ log .info ("wait for init" );
64
68
long start = System .currentTimeMillis ();
65
69
long end = start + deadline ;
66
70
while (!initialized && !isShutDown ) {
@@ -89,12 +93,14 @@ public void waitForInitialization(long deadline) {
89
93
if (isShutDown ) {
90
94
throw new IllegalStateException ("Already shut down" );
91
95
}
96
+ log .info ("post wait for init" );
92
97
}
93
98
94
99
/**
95
100
* Signals a shutdown. Threads waiting for initialization will wake up and throw an {@link IllegalStateException}.
96
101
*/
97
102
public synchronized void shutdown () {
103
+ log .info ("shutdown in wait" );
98
104
isShutDown = true ;
99
105
this .notifyAll ();
100
106
}
0 commit comments