@@ -67,32 +67,39 @@ private <T> FlagEvaluationDetails<T> evaluateFlag(FlagValueType type, String key
67
67
FlagEvaluationDetails <T > details = null ;
68
68
List <Hook > mergedHooks = null ;
69
69
HookContext <T > hookCtx = null ;
70
-
71
- try (AutoCloseableLock __ = OpenFeatureAPI .rwLock .readLockAutoCloseable ();
72
- AutoCloseableLock ___ = this .rwLock .readLockAutoCloseable ()) {
73
-
74
- FeatureProvider provider = ObjectUtils .defaultIfNull (openfeatureApi .getProvider (), () -> {
75
- log .debug ("No provider configured, using no-op provider." );
76
- return new NoOpProvider ();
77
- });
78
-
79
- hookCtx = HookContext .from (key , type , this .getMetadata (),
80
- openfeatureApi .getProvider ().getMetadata (), ctx , defaultValue );
81
-
82
- mergedHooks = ObjectUtils .merge (provider .getProviderHooks (), flagOptions .getHooks (), clientHooks ,
83
- openfeatureApi .getApiHooks ());
70
+ FeatureProvider provider = null ;
71
+
72
+ try {
73
+ EvaluationContext apiContext ;
74
+ EvaluationContext clientContext ;
75
+
76
+ // lock while getting the provider and hooks
77
+ try (AutoCloseableLock __ = OpenFeatureAPI .rwLock .readLockAutoCloseable ();
78
+ AutoCloseableLock ___ = this .rwLock .readLockAutoCloseable ()) {
79
+ provider = ObjectUtils .defaultIfNull (openfeatureApi .getProvider (), () -> {
80
+ log .debug ("No provider configured, using no-op provider." );
81
+ return new NoOpProvider ();
82
+ });
83
+
84
+ mergedHooks = ObjectUtils .merge (provider .getProviderHooks (), flagOptions .getHooks (), clientHooks ,
85
+ openfeatureApi .getApiHooks ());
86
+
87
+ hookCtx = HookContext .from (key , type , this .getMetadata (),
88
+ provider .getMetadata (), ctx , defaultValue );
89
+
90
+ // merge of: API.context, client.context, invocation.context
91
+ apiContext = openfeatureApi .getEvaluationContext () != null
92
+ ? openfeatureApi .getEvaluationContext ()
93
+ : new MutableContext ();
94
+ clientContext = openfeatureApi .getEvaluationContext () != null
95
+ ? this .getEvaluationContext ()
96
+ : new MutableContext ();
97
+ }
84
98
85
99
EvaluationContext ctxFromHook = hookSupport .beforeHooks (type , hookCtx , mergedHooks , hints );
86
100
87
101
EvaluationContext invocationCtx = ctx .merge (ctxFromHook );
88
102
89
- // merge of: API.context, client.context, invocation.context
90
- EvaluationContext apiContext = openfeatureApi .getEvaluationContext () != null
91
- ? openfeatureApi .getEvaluationContext ()
92
- : new MutableContext ();
93
- EvaluationContext clientContext = openfeatureApi .getEvaluationContext () != null
94
- ? this .getEvaluationContext ()
95
- : new MutableContext ();
96
103
EvaluationContext mergedCtx = apiContext .merge (clientContext .merge (invocationCtx ));
97
104
98
105
ProviderEvaluation <T > providerEval = (ProviderEvaluation <T >) createProviderEvaluation (type , key ,
0 commit comments