-
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
Changes from all commits
1b0dffa
f6a013c
c6a8855
2310f22
d4b0cfb
633c026
1046508
a839dfe
6626ea6
5cca0e0
12f7edb
6d04e1f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,13 @@ | ||||||||||||||||||||||||||||||||||||||||||
| package com.octopus.openfeature.provider; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| import com.fasterxml.jackson.databind.DeserializationFeature; | ||||||||||||||||||||||||||||||||||||||||||
| import com.fasterxml.jackson.databind.MapperFeature; | ||||||||||||||||||||||||||||||||||||||||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||||||||||||||||||||||||||||||||||||||||
| import com.fasterxml.jackson.databind.json.JsonMapper; | ||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||
| class OctopusObjectMapper { | ||||||||||||||||||||||||||||||||||||||||||
| static final ObjectMapper INSTANCE = JsonMapper.builder() | ||||||||||||||||||||||||||||||||||||||||||
| .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) | ||||||||||||||||||||||||||||||||||||||||||
| .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | ||||||||||||||||||||||||||||||||||||||||||
| .build(); | ||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+8
to
+12
|
||||||||||||||||||||||||||||||||||||||||||
| class OctopusObjectMapper { | |
| static final ObjectMapper INSTANCE = JsonMapper.builder() | |
| .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) | |
| .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | |
| .build(); | |
| final class OctopusObjectMapper { | |
| private static final ObjectMapper INSTANCE = JsonMapper.builder() | |
| .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES) | |
| .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) | |
| .build(); | |
| private OctopusObjectMapper() { | |
| // Utility class; prevent instantiation. | |
| } | |
| static ObjectMapper getInstance() { | |
| // Return a defensive copy to avoid shared mutable configuration. | |
| return INSTANCE.copy(); | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm...the whole point was to reuse the same instance. Making the wrapper final wouldn't hurt, but seems unnecessary?
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package com.octopus.openfeature.provider; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
|
||
| class Segment { | ||
| private final String key; | ||
| private final String value; | ||
|
|
||
| @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) | ||
| public Segment( | ||
| @JsonProperty(value = "key", required = true) String key, | ||
| @JsonProperty(value = "value", required = true) String value | ||
| ) { | ||
liamhughes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this.key = key; | ||
| this.value = value; | ||
| } | ||
|
|
||
| public String getKey() { | ||
| return key; | ||
| } | ||
|
|
||
| public String getValue() { | ||
| return value; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -0,0 +1,129 @@ | ||||
| package com.octopus.openfeature.provider; | ||||
|
|
||||
| import com.fasterxml.jackson.core.type.TypeReference; | ||||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||||
| import com.fasterxml.jackson.databind.exc.MismatchedInputException; | ||||
| import org.junit.jupiter.api.Test; | ||||
|
|
||||
| import java.io.InputStream; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|
||||
| import java.util.Map; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": false, | ||
| "segments": null | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": true, | ||
| "segments": null | ||
| } |
| 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 | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": true | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": true, | ||
| "segments": [ | ||
| {} | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": true, | ||
| "segments": [ | ||
| { | ||
| "value": "free" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| { | ||
| "name": "My Feature", | ||
| "slug": "my-feature", | ||
| "isEnabled": true, | ||
| "segments": [ | ||
| { | ||
| "key": "license-type" | ||
| } | ||
| ] | ||
| } |
| 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" | ||
| } | ||
| } |
| 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" | ||
| } | ||
| ] | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| [ | ||
| { | ||
| "NAME": "Feature A", | ||
| "SLUG": "feature-a", | ||
| "ISENABLED": true, | ||
| "SEGMENTS": [ | ||
| { | ||
| "KEY": "license-type", | ||
| "VALUE": "free" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "Name": "Feature B", | ||
| "Slug": "feature-b", | ||
| "IsEnabled": true, | ||
| "Segments": [ | ||
| { | ||
| "Key": "plan", | ||
| "Value": "enterprise" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "nAmE": "Feature C", | ||
| "sLuG": "feature-c", | ||
| "iSeNaBlEd": true, | ||
| "sEgMeNtS": [ | ||
| { | ||
| "kEy": "country", | ||
| "vAlUe": "au" | ||
| } | ||
| ] | ||
| } | ||
| ] |
Uh oh!
There was an error while loading. Please reload this page.