google / google/guice

Unordered JIT binding data

Open
#1,861 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

Hi,

We're running into cyclic dependencies intermittently in a large project with Guice, and figured that maintaining a specific order when configuring bindings should hopefully Guice to deterministically run into an unresolvable cycle or not.
This seems to work for the most part, but noticed that while most code in Guice carefully uses `LinkedHashSet` and `LinkedHashMap`, some use the non-ordered versions, for example https://github.com/google/guice/blob/master/core/src/com/google/inject/internal/InjectorJitBindingData.java#L18

As far as I can tell, this is not super relevant for actual bindings processing, but it was a bit surprising when trying to work out if our sorting logic works correctly when we looked through the bindings from `Injector.getAllBindings()` which had those JIT bindings in undefined order.

Would you be open to a patch changing these (and perhaps other places in the rest of the sources) from `Sets.newHashSet()` to `Sets.newLinkedHashSet()` and `Maps.newHashMap()` to `Maps.newLinkedHashMap()` ?

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.