Skip to content

feat: Added hook data #1506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

feat: Added hook data #1506

wants to merge 4 commits into from

Conversation

mdxabu
Copy link

@mdxabu mdxabu commented Jul 6, 2025

This PR

Added the Hook Data

  • adds this new feature

Related Issues

Fixes #1472

@beeme1mr, Please review this if there is any problem or if I did anything wrong, ping me!

@mdxabu mdxabu requested review from a team as code owners July 6, 2025 11:07
@mdxabu mdxabu changed the title Added hook data feat: Added hook data Jul 6, 2025
* Default thread-safe implementation of HookData.
*/
public class DefaultHookData implements HookData {
private final Map<String, Object> data = Collections.synchronizedMap(new HashMap<>());
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need a thread safe implementation? If the hook data only lives for the duraion of a flag evalution, there will probably not be concurrent access to this object. IIRC, a flag evaluation happens synchronously.

<T> T get(String key, Class<T> type);

/**
* Default implementation using ConcurrentHashMap for thread safety.
Copy link
Contributor

Choose a reason for hiding this comment

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

DefaultHookData uses a Collections.synchronizedMap(new HashMap<>()), not a ConcurrentHashMap

* Hook data provides a way for hooks to maintain state across their execution stages.
* Each hook instance gets its own isolated data store.
*/
HookData hookData;
Copy link
Contributor

Choose a reason for hiding this comment

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

With this addition, the Constructor of the HookContext changes, which may be a breaking change @toddbaert

@chrfwow
Copy link
Contributor

chrfwow commented Jul 7, 2025

@mdxabu you will need to force push a commit that is signed off, otherwise the DCO check will not succeed

@mdxabu
Copy link
Author

mdxabu commented Jul 7, 2025

@mdxabu you will need to force push a commit that is signed off, otherwise the DCO check will not succeed

Can I squash those commits into one commit, and then I will sign off?

@chrfwow
Copy link
Contributor

chrfwow commented Jul 7, 2025

Can I squash those commits into one commit, and then I will sign off?

Yes, you could do that. If you click on the failed DCO action, you schould see a short explanation

mdxabu added 2 commits July 7, 2025 21:23
Signed-off-by: mdxabu <[email protected]>
…d ConcurrentHashMap and use a synchronized HashMap instead

Signed-off-by: mdxabu <[email protected]>
@mdxabu
Copy link
Author

mdxabu commented Jul 7, 2025

@chrfwow, I force push the commits! Now DCO action runs successfully.

@mdxabu mdxabu requested a review from chrfwow July 8, 2025 04:54
@chrfwow
Copy link
Contributor

chrfwow commented Jul 8, 2025

The build currently fails because of formatting issues. You can resolve them automatically by running the spotless plugin

Copy link

codecov bot commented Jul 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 93.35%. Comparing base (62738f7) to head (e00885f).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1506      +/-   ##
============================================
+ Coverage     92.81%   93.35%   +0.53%     
- Complexity      486      491       +5     
============================================
  Files            46       47       +1     
  Lines          1169     1188      +19     
  Branches        103      107       +4     
============================================
+ Hits           1085     1109      +24     
+ Misses           54       49       -5     
  Partials         30       30              
Flag Coverage Δ
unittests 93.35% <100.00%> (+0.53%) ⬆️

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.

Copy link

sonarqubecloud bot commented Jul 8, 2025

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.

Add Hook Data
3 participants