Skip to content

Commit c2024e7

Browse files
committed
merge with main
Signed-off-by: christian.lutnik <[email protected]>
1 parent 2c9c843 commit c2024e7

File tree

2 files changed

+3
-26
lines changed

2 files changed

+3
-26
lines changed

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdProvider.java

-5
Original file line numberDiff line numberDiff line change
@@ -195,11 +195,6 @@ EvaluationContext getEnrichedContext() {
195195
private void onProviderEvent(FlagdProviderEvent flagdProviderEvent) {
196196
log.info("FlagdProviderEvent event {} ", flagdProviderEvent.getEvent());
197197
synchronized (syncResources) {
198-
syncResources.setSyncMetadata(flagdProviderEvent.getSyncMetadata());
199-
if (flagdProviderEvent.getSyncMetadata() != null) {
200-
syncResources.setEnrichedContext(contextEnricher.apply(flagdProviderEvent.getSyncMetadata()));
201-
}
202-
203198
/*
204199
* We only use Error and Ready as previous states.
205200
* As error will first be emitted as Stale, and only turns after a while into an

providers/flagd/src/main/java/dev/openfeature/contrib/providers/flagd/FlagdProviderSyncResources.java

+3-21
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,24 @@
22

33
import dev.openfeature.sdk.EvaluationContext;
44
import dev.openfeature.sdk.ImmutableContext;
5-
import dev.openfeature.sdk.ImmutableStructure;
65
import dev.openfeature.sdk.ProviderEvent;
7-
import dev.openfeature.sdk.Structure;
86
import dev.openfeature.sdk.exceptions.GeneralError;
97
import lombok.Getter;
108
import 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
1915
class 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

Comments
 (0)