1
1
package dev .openfeature .sdk .providers .memory ;
2
2
3
+ import dev .openfeature .sdk .ErrorCode ;
3
4
import dev .openfeature .sdk .EvaluationContext ;
4
5
import dev .openfeature .sdk .EventProvider ;
5
6
import dev .openfeature .sdk .Metadata ;
@@ -97,36 +98,36 @@ public void updateFlag(String flagKey, Flag<?> newFlag) {
97
98
@ Override
98
99
public ProviderEvaluation <Boolean > getBooleanEvaluation (
99
100
String key , Boolean defaultValue , EvaluationContext evaluationContext ) {
100
- return getEvaluation (key , evaluationContext , Boolean .class );
101
+ return getEvaluation (key , defaultValue , evaluationContext , Boolean .class );
101
102
}
102
103
103
104
@ Override
104
105
public ProviderEvaluation <String > getStringEvaluation (
105
106
String key , String defaultValue , EvaluationContext evaluationContext ) {
106
- return getEvaluation (key , evaluationContext , String .class );
107
+ return getEvaluation (key , defaultValue , evaluationContext , String .class );
107
108
}
108
109
109
110
@ Override
110
111
public ProviderEvaluation <Integer > getIntegerEvaluation (
111
112
String key , Integer defaultValue , EvaluationContext evaluationContext ) {
112
- return getEvaluation (key , evaluationContext , Integer .class );
113
+ return getEvaluation (key , defaultValue , evaluationContext , Integer .class );
113
114
}
114
115
115
116
@ Override
116
117
public ProviderEvaluation <Double > getDoubleEvaluation (
117
118
String key , Double defaultValue , EvaluationContext evaluationContext ) {
118
- return getEvaluation (key , evaluationContext , Double .class );
119
+ return getEvaluation (key , defaultValue , evaluationContext , Double .class );
119
120
}
120
121
121
122
@ SneakyThrows
122
123
@ Override
123
124
public ProviderEvaluation <Value > getObjectEvaluation (
124
125
String key , Value defaultValue , EvaluationContext evaluationContext ) {
125
- return getEvaluation (key , evaluationContext , Value .class );
126
+ return getEvaluation (key , defaultValue , evaluationContext , Value .class );
126
127
}
127
128
128
129
private <T > ProviderEvaluation <T > getEvaluation (
129
- String key , EvaluationContext evaluationContext , Class <?> expectedType ) throws OpenFeatureError {
130
+ String key , T defaultValue , EvaluationContext evaluationContext , Class <?> expectedType ) throws OpenFeatureError {
130
131
if (!ProviderState .READY .equals (state )) {
131
132
if (ProviderState .NOT_READY .equals (state )) {
132
133
throw new ProviderNotReadyError ("provider not yet initialized" );
@@ -140,6 +141,13 @@ private <T> ProviderEvaluation<T> getEvaluation(
140
141
if (flag == null ) {
141
142
throw new FlagNotFoundError ("flag " + key + " not found" );
142
143
}
144
+ if (flag .isDisabled ()) {
145
+ return ProviderEvaluation .<T >builder ()
146
+ .reason (Reason .DISABLED .name ())
147
+ .value (defaultValue )
148
+ .flagMetadata (flag .getFlagMetadata ())
149
+ .build ();
150
+ }
143
151
T value ;
144
152
Reason reason = Reason .STATIC ;
145
153
if (flag .getContextEvaluator () != null ) {
0 commit comments