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

Registered binders not iterated in registration order #4638

Closed
eocantu opened this issue Nov 12, 2020 · 1 comment
Closed

Registered binders not iterated in registration order #4638

eocantu opened this issue Nov 12, 2020 · 1 comment

Comments

@eocantu
Copy link

eocantu commented Nov 12, 2020

In our migration from jersey 2.25.1 to 2.32 we have noticed that the way in which registered binders are iterated is no longer deterministic. This is particularly problematic when different configuration order could lead to the wrong thing getting injected.

A similar issue was raised in #4538 but it doesn't seem like the fix addresses the issue for binders.

It seems to me the problem lies in the following code:

public Set<Object> getInstances(final Predicate<ContractProvider> filter) {
return instancesView.stream()
.filter(input -> {
final ContractProvider model = getModel(input.getClass());
return filter.test(model);
})
.collect(Collectors.toSet());
}

instances was originally created as a LinkedHashSet which is an ordered set, but the method above uses Collectors.toSet() which doesn't preserve order.

@eocantu eocantu changed the title Registered components not iterated in registration order Registered binders not iterated in registration order Nov 16, 2020
@jansupol
Copy link
Contributor

jansupol commented Dec 7, 2020

Fixed by #4648

@jansupol jansupol closed this as completed Dec 7, 2020
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

No branches or pull requests

2 participants