Skip to content
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

Strategy check return only the first enabled #210

Closed
gabritgtg opened this issue Aug 31, 2023 · 3 comments · Fixed by #211
Closed

Strategy check return only the first enabled #210

gabritgtg opened this issue Aug 31, 2023 · 3 comments · Fixed by #211
Assignees
Labels

Comments

@gabritgtg
Copy link

gabritgtg commented Aug 31, 2023

Describe the bug

In the [commit https://github.com/Unleash/unleash-client-java/commit/78a0d33358bb375d6abe8d08de60f704a12961a6](feat: strategy variants) has been introduced a bug.
When retrieving the toggle enabled strategies it is returned only the first. In case of multiple strategy the the toggle will result disabled even when the context is valid.

See into class src/main/java/io/getunleash/DefaultUnleash.java

        } else {
            enabledStrategy =
                    featureToggle.getStrategies().stream()
                            .filter(
                                    strategy -> {
                                        Strategy configuredStrategy =
                                                getStrategy(strategy.getName());
	@@ -181,13 +184,33 @@ private boolean checkEnabled(
                                        }

                                        return configuredStrategy.isEnabled(
                                                strategy.getParameters(), context);
                                    })
                            .findFirst();

Steps to reproduce the bug

  1. Create a toggle with more then one strategy
  2. Check if the toggle is enabled having as context valued that meet second or further strategy in the list.
  3. Should expect to return enabled true but is false

Expected behavior

When calling the method isEnabled with context that meet one of the strategy should expect true as response

Logs, error output, etc.

No response

Screenshots

No response

Additional context

No response

Unleash version

Subscription type

Enterprise

Hosting type

Hosted by Unleash

SDK information (language and version)

java, 8.3.0 ( introduced in this commit-78a0d33358bb375d6abe8d08de60f704a12961a6)

@gastonfournier
Copy link
Contributor

Thanks for the report! I currently managed to reproduce it locally, I'm working on a unit test and then trying to fix it. I believe you properly pointed at the issue with that findFirst, thanks!

@sighphyre
Copy link
Member

Hey @gabritgtg, this has been fixed in 8.3.1, which has been released, thank you so much for reporting this!

@gabritgtg
Copy link
Author

Thanks to everyone for the fast replay. You are a great team :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants