Skip to content

Commit 15155e6

Browse files
committed
build success
1 parent c4750b4 commit 15155e6

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

src/main/java/com/flagsmith/flagengine/segments/SegmentEvaluator.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,21 @@
1212
import com.jayway.jsonpath.Configuration;
1313
import com.jayway.jsonpath.JsonPath;
1414
import com.jayway.jsonpath.Option;
15-
import com.jayway.jsonpath.spi.json.JacksonJsonNodeJsonProvider;
16-
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider;
1715
import java.io.IOException;
1816
import java.util.ArrayList;
1917
import java.util.Arrays;
2018
import java.util.List;
19+
import java.util.Map;
2120
import java.util.function.Predicate;
2221
import java.util.regex.Pattern;
2322
import java.util.regex.PatternSyntaxException;
2423
import java.util.stream.Collectors;
25-
import java.util.stream.Stream;
2624

2725
public class SegmentEvaluator {
2826
private static ObjectMapper mapper = new ObjectMapper();
29-
private static Configuration jacksonNodeConf = Configuration.builder()
30-
.jsonProvider(new JacksonJsonNodeJsonProvider())
31-
.mappingProvider(new JacksonMappingProvider(mapper))
32-
.options(Option.DEFAULT_PATH_LEAF_TO_NULL)
33-
.build();
27+
private static Configuration jsonPathConfiguration = Configuration
28+
.defaultConfiguration()
29+
.setOptions(Option.SUPPRESS_EXCEPTIONS);
3430

3531
/**
3632
* Check if context is in segment.
@@ -107,7 +103,7 @@ private static Boolean contextMatchesCondition(
107103
}
108104

109105
if (!(contextValue instanceof Boolean)) {
110-
contextValue = contextValue.toString();
106+
contextValue = String.valueOf(contextValue);
111107
}
112108

113109
return conditionList.contains(contextValue);
@@ -198,7 +194,10 @@ private static Boolean contextMatchesCondition(
198194
*/
199195
private static Object getContextValue(EvaluationContext context, String property) {
200196
if (property.startsWith("$.")) {
201-
return JsonPath.using(jacksonNodeConf).parse(mapper.valueToTree(context)).read(property);
197+
return JsonPath
198+
.using(jsonPathConfiguration)
199+
.parse(mapper.convertValue(context, Map.class))
200+
.read(property);
202201
}
203202
if (context.getIdentity() != null) {
204203
return context.getIdentity().getTraits().getAdditionalProperties().get(property);

src/main/java/com/flagsmith/models/Flags.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public static Flags fromEvaluationResult(
127127
Map<String, BaseFlag> flagMap = evaluationResult.getFlags().stream()
128128
.collect(
129129
Collectors.toMap(
130-
(fs) -> fs.getFeatureKey(),
130+
(fs) -> fs.getName(),
131131
(fs) -> {
132132
Flag flag = new Flag();
133133
flag.setFeatureName(fs.getName());

src/test/java/com/flagsmith/FlagsmithClientTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,12 +624,17 @@ public void testUpdateEnvironment_StoresIdentityOverrides_WhenGetEnvironmentRetu
624624
// Given
625625
EvaluationContext evaluationContext = FlagsmithTestHelper.evaluationContext();
626626

627+
FlagsmithConfig config = FlagsmithConfig.newBuilder()
628+
.withLocalEvaluation(true)
629+
.build();
630+
627631
FlagsmithApiWrapper mockApiWrapper = mock(FlagsmithApiWrapper.class);
628632
when(mockApiWrapper.getEvaluationContext()).thenReturn(evaluationContext);
633+
when(mockApiWrapper.getConfig()).thenReturn(config);
629634

630635
FlagsmithClient client = FlagsmithClient.newBuilder()
631636
.withFlagsmithApiWrapper(mockApiWrapper)
632-
.withConfiguration(FlagsmithConfig.newBuilder().withLocalEvaluation(true).build())
637+
.withConfiguration(config)
633638
.setApiKey("ser.dummy-key")
634639
.build();
635640

src/test/java/com/flagsmith/flagengine/EngineTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ public void testEngine(EvaluationContext evaluationContext, JsonNode expectedRes
9797
FeatureStateModel fsm = flags.get(i);
9898
FlagResult fr = sortedResults.get(i);
9999

100-
assertEquals(fr.getName(), fsm.getFeature().getName());
101-
assertEquals(fr.getEnabled(), fsm.getEnabled());
102-
assertEquals(fr.getValue(), fsm.getValue());
100+
assertEquals(fsm.getFeature().getName(), fr.getName());
101+
assertEquals(fsm.getEnabled(), fr.getEnabled());
102+
assertEquals(fsm.getValue(), fr.getValue());
103103
}
104104
}
105105
}

0 commit comments

Comments
 (0)