Skip to content

Conversation

@toddbaert
Copy link
Member

@toddbaert toddbaert commented Dec 8, 2025

This reverts commit 6f3a30a, which causes significant issues (serialization of context doesn't work, most/all attributes seem to be missing, see open-feature/java-sdk-contrib#1665 for a demo).

#1756

This reverts commit 6f3a30a.

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
@toddbaert toddbaert requested review from a team as code owners December 8, 2025 22:54
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @toddbaert, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request serves as a revert of a previous commit, aiming to refine the handling of context serialization and equality within the SDK. It simplifies the ImmutableContext by delegating equals() and hashCode() generation to Lombok, and streamlines LayeredEvaluationContext by removing its attribute map caching and reverting its equality semantics to default object reference comparison. These changes are intended to improve code maintainability and address any complexities introduced by the prior implementation.

Highlights

  • ImmutableContext Simplification: The ImmutableContext class now leverages Lombok's @EqualsAndHashCode annotation for automatic generation of equals() and hashCode() methods, removing the need for manual implementations and a cached hash code field.
  • LayeredEvaluationContext Refactoring: The LayeredEvaluationContext has been refactored to remove its internal caching mechanism for resolved attribute maps. The asMap() method now constructs the map on demand, and its custom equals() and hashCode() methods have been removed, reverting to default object reference equality.
  • asObjectMap Rework: The asObjectMap() method within LayeredEvaluationContext has been re-implemented to directly merge object maps from its constituent contexts, streamlining its logic.
  • Test Suite Alignment: Corresponding test cases for the removed manual equals() and hashCode() implementations in both ImmutableContext and LayeredEvaluationContext have been removed, and a new test verifies the Lombok-generated equals() for ImmutableContext.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 8, 2025

@toddbaert toddbaert changed the title fix: context serialization with revert fix: context serialization missing props (with revert) Dec 8, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors ImmutableContext and LayeredEvaluationContext. In ImmutableContext, manual equals() and hashCode() implementations and a cachedHashCode field were removed in favor of Lombok's @EqualsAndHashCode annotation. Corresponding test cases were adjusted, and minor display name corrections were suggested by the reviewer for ImmutableContext equality tests. In LayeredEvaluationContext, the cachedMap field and its caching logic were removed, simplifying asMap() and asObjectMap() to construct maps on demand. The manual equals() and hashCode() methods were also removed from LayeredEvaluationContext, which the reviewer identified as a significant behavioral change, reverting to identity-based equality inconsistent with other EvaluationContext implementations. The reviewer recommended re-implementing value-based equals() and hashCode() for LayeredEvaluationContext to ensure consistent behavior and prevent issues in collections, such as by delegating to asMap().

return map;
}

void putHookContext(EvaluationContext context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The equals() and hashCode() methods have been removed from this class. This reverts to Object's identity-based equality, which is inconsistent with other EvaluationContext implementations like ImmutableContext and MutableContext that provide value-based equality. This is a significant behavioral change that could break consumers relying on value comparison (e.g., in collections).

If this was an unintended side-effect of removing the caching logic, please consider re-implementing equals() and hashCode() to restore value semantics, for example by delegating to asMap(). Without this, LayeredEvaluationContext will not behave as expected in HashMaps or other collections that rely on equals.

}

@DisplayName("Two different ImmutableContext objects with different contents are not considered equal")
@DisplayName("Two different MutableContext objects with the different contents are not considered equal")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The display name for this test seems to have a copy-paste error, as it refers to MutableContext in a test for ImmutableContext. This should be corrected for clarity in test reports.

Suggested change
@DisplayName("Two different MutableContext objects with the different contents are not considered equal")
@DisplayName("Two different ImmutableContext objects with different contents are not considered equal")

}

@DisplayName("ImmutableContext hashCode is stable across multiple invocations")
@DisplayName("Two different MutableContext objects with the same content are considered equal")
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The display name for this test incorrectly refers to MutableContext instead of ImmutableContext. This should be corrected for clarity.

Suggested change
@DisplayName("Two different MutableContext objects with the same content are considered equal")
@DisplayName("Two ImmutableContext objects with the same content are considered equal")

@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.66%. Comparing base (04feac8) to head (bdbcd99).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1768      +/-   ##
============================================
+ Coverage     92.08%   93.66%   +1.58%     
- Complexity      601      602       +1     
============================================
  Files            55       55              
  Lines          1427     1406      -21     
  Branches        156      154       -2     
============================================
+ Hits           1314     1317       +3     
+ Misses           67       50      -17     
+ Partials         46       39       -7     
Flag Coverage Δ
unittests 93.66% <100.00%> (+1.58%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@toddbaert toddbaert merged commit 4cb39a4 into main Dec 8, 2025
14 of 17 checks passed
@toddbaert toddbaert deleted the fix/context-serialization branch December 8, 2025 22:59
chrfwow added a commit to chrfwow/java-sdk that referenced this pull request Dec 9, 2025
toddbaert pushed a commit to chrfwow/java-sdk that referenced this pull request Dec 9, 2025
This reverts commit 4cb39a4.

Co-authored-by: vishalup29 <vishalupadhyay977@gmail.com>
toddbaert pushed a commit to chrfwow/java-sdk that referenced this pull request Dec 9, 2025
This reverts commit 4cb39a4.

Co-authored-by: Vishalup29 <67001661+Vishalup29@users.noreply.github.com>
toddbaert pushed a commit to chrfwow/java-sdk that referenced this pull request Dec 9, 2025
This reverts commit 4cb39a4.

Co-authored-by: Vishalup29 <67001661+Vishalup29@users.noreply.github.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
toddbaert pushed a commit to chrfwow/java-sdk that referenced this pull request Dec 9, 2025
toddbaert pushed a commit to chrfwow/java-sdk that referenced this pull request Dec 9, 2025
This reverts commit 4cb39a4.

Co-Authored-By: Vishalup29 <67001661+Vishalup29@users.noreply.github.com>
Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
toddbaert pushed a commit that referenced this pull request Dec 9, 2025
fix: .equals false for equivalent contexts (#1768)"

This reverts commit 4cb39a4.

Signed-off-by: Todd Baert <todd.baert@dynatrace.com>
Co-authored-by: Vishalup29 <67001661+Vishalup29@users.noreply.github.com>
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.

2 participants