fix: update the java openfeature examples to be compliant with openfeature#964
Merged
fix: update the java openfeature examples to be compliant with openfeature#964
Conversation
Deploying devcycle-docs with
|
| Latest commit: |
3f359f1
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1ebdb76d.devcycle-docs.pages.dev |
| Branch Preview URL: | https://parthsuthar-update-java-of-a.devcycle-docs.pages.dev |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the Java OpenFeature provider documentation examples to better match the OpenFeature Java API (notably by consistently using an EvaluationContext when evaluating flags).
Changes:
- Expand the “Evaluate a Variable” example to evaluate multiple flag types using a shared
MutableContext. - Update JSON flag examples to pass
contextintogetObjectValue(...)calls. - Add an example of converting a returned
Valueback into aMap<String, Object>for JSON-object flags.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
182
to
186
| // Convert the returned Value back to a Map<String, Object> | ||
| Map<String, Object> jsonMap = jsonResult.asStructure().asObjectMap(); | ||
| ``` | ||
|
|
||
| This is enforced both for both the flag values and the default values supplied to the `getObjectValue()` method. Invalid types will trigger a `dev.openfeature.sdk.exceptions.TypeMismatchError` exception. |
Comment on lines
+165
to
+170
| // Invalid JSON values for the DevCycle SDK, will return defaults | ||
| openFeatureClient.getObjectValue("json-flag", new Value(new ArrayList<String>(Arrays.asList("value1", "value2")))); | ||
| openFeatureClient.getObjectValue("json-flag", new Value(610)); | ||
| openFeatureClient.getObjectValue("json-flag", new Value(false)); | ||
| openFeatureClient.getObjectValue("json-flag", new Value("string")); | ||
| openFeatureClient.getObjectValue("json-flag", new Value()); | ||
| Value listResult = openFeatureClient.getObjectValue("json-flag", new Value(new ArrayList<String>(Arrays.asList("value1", "value2"))), context); | ||
| Value intResult = openFeatureClient.getObjectValue("json-flag", new Value(610), context); | ||
| Value boolResult = openFeatureClient.getObjectValue("json-flag", new Value(false), context); | ||
| Value stringResult = openFeatureClient.getObjectValue("json-flag", new Value("string"), context); | ||
| Value nullResult = openFeatureClient.getObjectValue("json-flag", new Value(), context); |
leslie-lau
requested changes
Mar 19, 2026
jonathannorris
approved these changes
Mar 19, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
update the openfeature client to include the context, add example of parsing ObjectValue from openfeature client