cdi-inject-weld: make SupplierContractsTest deterministic#6022
Open
minizhiren wants to merge 1 commit intoeclipse-ee4j:2.xfrom
Open
cdi-inject-weld: make SupplierContractsTest deterministic#6022minizhiren wants to merge 1 commit intoeclipse-ee4j:2.xfrom
minizhiren wants to merge 1 commit intoeclipse-ee4j:2.xfrom
Conversation
Member
|
It is difficult to check this because text has been reformatted. Could you restore the previous format, please?. |
Author
|
Sure! My pleasure! |
6769255 to
54d8485
Compare
jbescos
reviewed
Dec 18, 2025
Comment on lines
+326
to
+335
| // ---------- ClassBinding ---------- | ||
| if (ClassBinding.class.isAssignableFrom(binding.getClass())) { | ||
| final ClassBinding<?> cb = (ClassBinding<?>) binding; | ||
|
|
||
| // Keep existing "update" path for CLIENT | ||
| if (RuntimeType.CLIENT == runtimeType) { | ||
| for (Type contract : ((ClassBinding<?>) binding).getContracts()) { | ||
| final List<BindingBeanPair> preregistered = classBindings.get(contract); | ||
| if (preregistered != null && preregistered.size() == 1) { | ||
| BeanHelper.updateBean( | ||
| (ClassBinding<?>) binding, preregistered.get(0), injectionResolvers, beanManager); | ||
| for (Type contract : cb.getContracts()) { | ||
| final java.util.List<BindingBeanPair> pre = classBindings.get(contract); | ||
| if (pre != null && pre.size() == 1) { | ||
| BeanHelper.updateBean(cb, pre.get(0), injectionResolvers, beanManager); |
Member
There was a problem hiding this comment.
This section of here is is just renaming, right?. It does not modify any functionality.
I suggest to not do this refactoring because of two reasons:
- It is more difficult to focus in the real change of the PR.
- It adds noise when you want track changes of a file.
jbescos
reviewed
Dec 18, 2025
Comment on lines
+354
to
+365
|
|
||
| // ---------- SupplierClassBinding ---------- | ||
| } else if (SupplierClassBinding.class.isAssignableFrom(binding.getClass())) { | ||
| final SupplierClassBinding<?> scb = (SupplierClassBinding<?>) binding; | ||
|
|
||
| // Keep existing "update" path for CLIENT | ||
| if (RuntimeType.CLIENT == runtimeType) { | ||
| for (Type contract : ((SupplierClassBinding<?>) binding).getContracts()) { | ||
| final List<BindingBeanPair> preregistered = supplierClassBindings.get(contract); | ||
| if (preregistered != null && preregistered.size() == 1) { | ||
| for (Type contract : scb.getContracts()) { | ||
| final java.util.List<BindingBeanPair> pre = supplierClassBindings.get(contract); | ||
| if (pre != null && pre.size() == 1) { | ||
| BeanHelper.updateSupplierBean( | ||
| (SupplierClassBinding<?>) binding, preregistered.get(0), injectionResolvers, beanManager); | ||
| scb, pre.get(0), injectionResolvers, beanManager); |
Member
There was a problem hiding this comment.
This is also refactoring, that we can avoid in this PR.
jbescos
reviewed
Dec 18, 2025
Comment on lines
+385
to
+402
| // ---------- Instance bindings (unchanged) ---------- | ||
| } else if (InitializableInstanceBinding.class.isAssignableFrom(binding.getClass())) { | ||
| if (RuntimeType.SERVER == runtimeType | ||
| || !matchInitializableInstanceBinding((InitializableInstanceBinding<?>) binding)) { | ||
| initializableInstanceBindings.add((InitializableInstanceBinding<?>) binding); | ||
| BeanHelper.registerBean( | ||
| runtimeType, (InitializableInstanceBinding<?>) binding, abd, injectionResolvers, beanManager); | ||
| runtimeType, (InitializableInstanceBinding<?>) binding, | ||
| abd, injectionResolvers, beanManager); | ||
| } | ||
| } else if (InitializableSupplierInstanceBinding.class.isInstance(binding)) { | ||
| if (RuntimeType.SERVER == runtimeType | ||
| || !matchInitializableSupplierInstanceBinding((InitializableSupplierInstanceBinding) binding)) { | ||
| initializableSupplierInstanceBindings.add((InitializableSupplierInstanceBinding) binding); | ||
| BeanHelper.registerSupplier(runtimeType, (InitializableSupplierInstanceBinding<?>) binding, abd, beanManager); | ||
| || !matchInitializableSupplierInstanceBinding( | ||
| (InitializableSupplierInstanceBinding) binding)) { | ||
| initializableSupplierInstanceBindings.add( | ||
| (InitializableSupplierInstanceBinding) binding); | ||
| BeanHelper.registerSupplier( | ||
| runtimeType, (InitializableSupplierInstanceBinding<?>) binding, | ||
| abd, beanManager); |
Contributor
|
@minizhiren I am not quite sure what the purpose of this PR is. Do you use the module with 2.x Jersey? Or is the purpose to just to fix the test? I am just curious about the usage of this module by the community. This module is meant to be used mainly in EE 12, and there was a significant development in the latest (4.0/4.0.JPMS) branch. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause: binder registration order and reuse were nondeterministic, causing SupplierContractsTest to be flaky.
Fix: register bindings deterministically and reuse them safely (IdentityHashMap for insertion-order semantics; cleanup of binder cache).
Test: SupplierContractsTest now passes reliably across runs/seeds.