Skip to content

fix: update the java openfeature examples to be compliant with openfeature#964

Merged
suthar26 merged 2 commits intomainfrom
parthsuthar/update-java-of-accessor
Mar 19, 2026
Merged

fix: update the java openfeature examples to be compliant with openfeature#964
suthar26 merged 2 commits intomainfrom
parthsuthar/update-java-of-accessor

Conversation

@suthar26
Copy link
Contributor

@suthar26 suthar26 commented Mar 19, 2026

update the openfeature client to include the context, add example of parsing ObjectValue from openfeature client

Copilot AI review requested due to automatic review settings March 19, 2026 17:08
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 19, 2026

Deploying devcycle-docs with  Cloudflare Pages  Cloudflare Pages

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

View logs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 context into getObjectValue(...) calls.
  • Add an example of converting a returned Value back into a Map<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);
@suthar26 suthar26 requested a review from leslie-lau March 19, 2026 20:30
Copy link
Contributor

@leslie-lau leslie-lau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@suthar26 suthar26 merged commit 99258d4 into main Mar 19, 2026
5 checks passed
@suthar26 suthar26 deleted the parthsuthar/update-java-of-accessor branch March 19, 2026 20:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants