-
Notifications
You must be signed in to change notification settings - Fork 0
Fix: client breaks when evaluation contains segments or unknown response fields #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
liamhughes
merged 12 commits into
main
from
liamhughes/devex-80-java-client-breaks-on-segments-and-new-response-fields
Mar 27, 2026
Merged
Changes from 2 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
1b0dffa
JSON deserialisation tests
liamhughes f6a013c
Apply fixes
liamhughes c6a8855
Add more checks during segment deserialisation
liamhughes 2310f22
Add SegmentDeserializerTests
liamhughes d4b0cfb
Idiomatic handling of null warnings
liamhughes 633c026
SimpleImmutableEntry
liamhughes 1046508
Make deserialisation case insensitive
liamhughes a839dfe
Replace Map.Entry<String, String> with Segment
liamhughes 6626ea6
Make getSegments return immutable
liamhughes 5cca0e0
Clean up
liamhughes 12f7edb
Make ObjectMapper static for performance
liamhughes 6d04e1f
Make Segment key and value required
liamhughes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
13 changes: 10 additions & 3 deletions
13
src/main/java/com/octopus/openfeature/provider/FeatureToggleEvaluation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/main/java/com/octopus/openfeature/provider/SegmentDeserializer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package com.octopus.openfeature.provider; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonParser; | ||
| import com.fasterxml.jackson.databind.DeserializationContext; | ||
| import com.fasterxml.jackson.databind.JsonDeserializer; | ||
| import com.fasterxml.jackson.databind.JsonNode; | ||
|
|
||
| import java.io.IOException; | ||
| import java.util.AbstractMap; | ||
| import java.util.Map; | ||
|
|
||
| class SegmentDeserializer extends JsonDeserializer<Map.Entry<String, String>> { | ||
| @Override | ||
| public Map.Entry<String, String> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { | ||
| JsonNode node = p.getCodec().readTree(p); | ||
| String key = node.get("key").asText(); | ||
| String value = node.get("value").asText(); | ||
| return new AbstractMap.SimpleEntry<>(key, value); | ||
| } | ||
| } | ||
82 changes: 82 additions & 0 deletions
82
...st/java/com/octopus/openfeature/provider/FeatureToggleEvaluationDeserializationTests.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,82 @@ | ||||
| package com.octopus.openfeature.provider; | ||||
|
|
||||
| import com.fasterxml.jackson.core.type.TypeReference; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import org.junit.jupiter.api.Test; | ||||
|
|
||||
| import java.io.InputStream; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|
||||
| import java.util.Map; |
6 changes: 6 additions & 0 deletions
6
src/test/resources/com/octopus/openfeature/provider/toggle-disabled.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": false, | ||
| "segments": null | ||
| } |
6 changes: 6 additions & 0 deletions
6
src/test/resources/com/octopus/openfeature/provider/toggle-enabled-no-segments.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": true, | ||
| "segments": null | ||
| } |
14 changes: 14 additions & 0 deletions
14
src/test/resources/com/octopus/openfeature/provider/toggle-list.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| [ | ||
| { | ||
| "name": "Feature A", | ||
| "slug": "feature-a", | ||
| "isEnabled": true, | ||
| "segments": null | ||
| }, | ||
| { | ||
| "name": "Feature B", | ||
| "slug": "feature-b", | ||
| "isEnabled": false, | ||
| "segments": null | ||
| } | ||
| ] |
5 changes: 5 additions & 0 deletions
5
src/test/resources/com/octopus/openfeature/provider/toggle-missing-segments.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": true | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/test/resources/com/octopus/openfeature/provider/toggle-with-extraneous-properties.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": true, | ||
| "segments": [ | ||
| { | ||
| "key": "license-type", | ||
| "value": "free", | ||
| "more": "data" | ||
| } | ||
| ], | ||
| "foo": "bar", | ||
| "qux": 123, | ||
| "wux": { | ||
| "nested": "value" | ||
| } | ||
| } |
15 changes: 15 additions & 0 deletions
15
src/test/resources/com/octopus/openfeature/provider/toggle-with-segments.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": true, | ||
| "segments": [ | ||
| { | ||
| "key": "license-type", | ||
| "value": "free" | ||
| }, | ||
| { | ||
| "key": "country", | ||
| "value": "au" | ||
| } | ||
| ] | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.