Skip to content

WICKET-7126 simplify CdiConfiguration + BeanManagerLookup#1369

Open
pedrosans wants to merge 1 commit intomasterfrom
pedro/cdi-improvement
Open

WICKET-7126 simplify CdiConfiguration + BeanManagerLookup#1369
pedrosans wants to merge 1 commit intomasterfrom
pedro/cdi-improvement

Conversation

@pedrosans
Copy link
Contributor

@pedrosans pedrosans commented Feb 15, 2026

This change cleans up CdiConfiguration and BeanManagerLookup by removing some logic and state related to fallbackBeanManager and lastSuccessful strategy, while removing none of the functionality. For instance, it's still possible to have a fallback BeanManager as a config option if the current lookup fail:

bm = BeanManagerLookup.lookup();
if (bm == null)
bm = customBeamManager;
new CdiConfiguration(bm);

Another benefit of this change is the reduced number of times the new code will make expensive (time consuming) JNDI lookups.

@pedrosans
Copy link
Contributor Author

build fails with:

Error: Failed to execute goal com.github.siom79.japicmp:japicmp-maven-plugin:0.25.4:cmp (default) on project wicket-cdi: There is at least one incompatibility: org.apache.wicket.cdi.CdiConfiguration.getFallbackBeanManager():METHOD_REMOVED,org.apache.wicket.cdi.CdiConfiguration.setFallbackBeanManager(jakarta.enterprise.inject.spi.BeanManager):METHOD_REMOVED -> [Help 1]

but the current version (11.0.0-SNAPSHOT) has no previous 11.0.x one to be incompatible. Let me know if it's the case to better setup the japicmp tool or to ignore (if possible) the fail.

@martin-g
Copy link
Member

martin-g commented Feb 16, 2026

The plugin should be disabled in master branch until 11.0.0 is released.

@martin-g martin-g requested a review from papegaaij February 16, 2026 06:32
Copy link
Member

@martin-g martin-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another benefit of this change is the reduced number of times the new code will make expensive (time consuming) JNDI lookups.

Is it really ?
Before there was a BeanManagerLookup#lastSuccessful cache. Now it is gone and every BeanManagerLookup#lookup() always makes two JNDI lookups.

{
this.fallbackBeanManager = fallbackBeanManager;
return this;
"app not configured or no BeanManager was resolved during the configuration");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message is vague and does not suggest actionable guidance for the developers.


private static BeanManagerLookupStrategy lastSuccessful = BeanManagerLookupStrategy.CUSTOM;

private BeanManagerLookup()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this constructor removed ?
This is a utility class with a single static method.


public CdiConfiguration(BeanManager beanManager)
{
this.beanManager = beanManager;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a non-null check ?!
Otherwise, it behaves as the no-arg constructor if null is passed.

throw new IllegalStateException(
"No BeanManager found via the CDI provider and no fallback specified. Check your "
+ "CDI setup or specify a fallback BeanManager in the CdiConfiguration.");
return null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit here of returning null than throwing an exception ?

Comment on lines +80 to +81
if(beanManager == null)
beanManager = BeanManagerLookup.lookup();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if(beanManager == null)
beanManager = BeanManagerLookup.lookup();
if (beanManager == null)
{
beanManager = BeanManagerLookup.lookup();
}

Comment on lines +83 to +85
if (beanManager == null)
throw new IllegalStateException(
"No BeanManager was set or found via the CDI provider. Check your CDI setup or specify a BeanManager in the CdiConfiguration.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (beanManager == null)
throw new IllegalStateException(
"No BeanManager was set or found via the CDI provider. Check your CDI setup or specify a BeanManager in the CdiConfiguration.");
if (beanManager == null)
{
throw new IllegalStateException(
"No BeanManager was set or found via the CDI provider. Check your CDI setup or specify a BeanManager in the CdiConfiguration.");
}

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

Successfully merging this pull request may close these issues.

2 participants