docs: fix inaccuracies in README code examples#1931
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the README.md to correct environment variable usage, simplify API calls, and fix a missing 'new' keyword in a provider instantiation. It also updates the Hook implementation example to include generic types. A review comment correctly identified that the 'before' method in the Hook example is missing a return statement, which would cause a compilation error.
0a7d379 to
eba3402
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates the README’s Java snippets to better reflect the actual Java SDK APIs and to avoid compilation issues in the documentation examples.
Changes:
- Fix incorrect usage of Java environment variable APIs in the targeting example.
- Simplify client acquisition to use
api.getClient()directly. - Update hook example signatures to match the generic
Hook<T>interface.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The raw-type version compiles but emits 12 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1931 +/- ##
============================================
+ Coverage 92.11% 93.10% +0.98%
- Complexity 660 663 +3
============================================
Files 59 59
Lines 1624 1624
Branches 182 182
============================================
+ Hits 1496 1512 +16
+ Misses 80 66 -14
+ Partials 48 46 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
eba3402 to
b7ac0b0
Compare
b7ac0b0 to
bd53036
Compare
|
Signed-off-by: Jonathan Norris <jonathan.norris@dynatrace.com>
bd53036 to
e7e148f
Compare
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThree Java code snippets in ChangesREADME Snippet Corrections
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Comment |
|



Summary
Changes
System.getEnv("us-east-1")(both occurrences). The method isSystem.getenv(...)(lowercasee—getEnvdoes not exist in Java). The argument was also wrong —"us-east-1"is a region value, not an env var name. Changed toSystem.getenv("AWS_REGION")which reads the region from the environment variableapi.getInstance().getClient()toapi.getClient(). CallinggetInstance()(a static method) through theapiinstance reference is redundant sinceapiwas already assigned the singleton on the line abovenewkeyword insetProvider(LocalProvider())— withoutnew, Java parses it as a method call to a nonexistent staticLocalProvider()method, causing a compile errorHook<T>interface signatures:Hook->Hook<Object>HookContext ctx->HookContext<Object> ctxMap hints->Map<String, Object> hintsOptional(return ofbefore) ->Optional<EvaluationContext>FlagEvaluationDetails details->FlagEvaluationDetails<Object> detailsreturn Optional.empty();tobefore(). Once the return type is parameterized asOptional<EvaluationContext>(instead of rawOptional), a missing return becomes a compile error rather than silently compilingAll fixed examples were verified to compile cleanly against the current main branch. Original broken versions were confirmed to fail compilation.
Summary by CodeRabbit