Repository navigation
Conversation
Co-authored-by: cgcote <5115638+cgcote@users.noreply.github.com>
Contributor
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
This branch has not been deployed
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.
What Does This Do
When a numeric flag condition (for example
ONE_OFagainst a list with anullelement) compares anullvalue, the OpenFeature provider now always reports the sameErrorCode.GENERALerror message:Cannot compare a null value as a number. Before this change, the message was either the JDK's helpful-NPE text ornull, depending on JIT state. Behavior for non-null values is unchanged.Motivation
Root cause:
FlagEvaluator.toDouble(Object)returnedmapValue(Double.class, value)into a primitivedouble. Fornull,mapValuereturnsnull, so the implicit unboxing threw aNullPointerException. The outercatch (Exception e)then usede.getMessage()as the evaluation error message. When this implicit NPE site gets hot and C2 compiles it, HotSpot'sOmitStackTraceInFastThrowswitches to a preallocated NPE that has no message. The user-visible error message, and the test assertion on it, therefore depended on how warm the JVM was.Evidence:
-XX:-OmitStackTraceInFastThrow.Impact (Datadog Flaky Test Management):
com.datadog.openfeature.internal.evaluation.FlagEvaluatorTest.reportsANullListElementAsMapValueDoes().expected: <Cannot invoke "java.lang.Double.doubleValue()" because the return value of "...FlagEvaluator.mapValue(java.lang.Class, Object)" is null> but was: <null>.b71a017058fcec85. Attempt-to-fix ID:99ETNB(DD_99ETNB).Additional Notes
Change:
toDoublehandlesnullexplicitly and still throws an NPE, so the error code staysGENERALthrough the same catch block.FlagEvaluatorTestandFlagEvaluatorMembershipTestassert the exact new message. The JDK<15assumeTrueguard is removed because the message now exists on every JDK.OmitStackTraceInFastThrowfor tests. I didn't pick it because it would hide a real production nondeterminism.Testing (run in the Bits Code session, as reported by the session):
./gradlew :dd-openfeature:test --tests 'com.datadog.openfeature.internal.evaluation.FlagEvaluatorTest' --rerun, 3 runs: 39 passed each time../gradlew :dd-openfeature:test --tests 'com.datadog.openfeature.internal.evaluation.*' --rerun: 113 passed. The same with-PtestJvm=21and with-PtestJvm=25: 113 passed each../gradlew :dd-openfeature:test: 1,733 passed, 6 existing fixture cases skipped../gradlew :dd-openfeature:spotlessCheck: passed.Risks: Low. The only behavior change is the text of the error message for null numeric comparisons. The previous text was already nondeterministic. There are no sleeps, timeout changes, relaxed assertions or quarantines.
Prepared in Bits Code session: https://app.datadoghq.com/code/1c28348e-ca80-448c-a3fd-05b281138568
This PR was opened by the dd-trace Flaky-Test ROI Recommender via Bits Code.
Contributor Checklist
type: bug fix,comp: openfeatureandtag: ai generated.Jira ticket: N/A
PR by Bits - View session in Datadog
Comment @DataDog to request changes