eclipse-ee4j / eclipse-ee4j/jersey
Unable to register multiple instances of the same `Binder` class
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
### Description
While writing the test case for #3675, I've noticed that it doesn't seem to be possible to register two instances of the same `Binder` class (either Jersey binder or HK2 binder).
Technically, the main cause seems to be in `ComponentBag#registerModel`:
```java
private boolean registerModel(final Class componentClass,
final int defaultPriority,
final Map, Integer> contractMap,
final Inflector modelEnhancer) {
return Errors.process(() -> {
if (models.containsKey(componentClass)) { // <-- true for the second binder!
Errors.error(LocalizationMessages.COMPONENT_TYPE_ALREADY_REGISTERED(componentClass), Severity.HINT);
return false;
}
...
});
}
```
Is this by design?
### Test
* https://github.com/fabriziocucci/jersey-issue-3686
Contributor guide
Research direction
Start with the reproduction at https://github.com/fabriziocucci/jersey-issue-3686, then inspect ComponentBag#registerModel and the models.containsKey(componentClass) path. Determine whether registering multiple Jersey or HK2 Binder instances is intended, and use the reproduction test to define the expected behavior and verify the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100