This is an automated email from the ASF dual-hosted git repository.
reta pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/main by this push:
new d94f8f6c5e [cdi] semuru does not have a native Object.hashCode so OWB
proxies hashCode (request scoped for ex) and hashset triggering a hashCode in
CDI extension it can fail since there is no request scope there by default
(#1794)
d94f8f6c5e is described below
commit d94f8f6c5efd1ea26b11d01c979a0d1af79bf1b8
Author: Romain Manni-Bucau <[email protected]>
AuthorDate: Tue Apr 9 17:43:42 2024 +0200
[cdi] semuru does not have a native Object.hashCode so OWB proxies hashCode
(request scoped for ex) and hashset triggering a hashCode in CDI extension it
can fail since there is no request scope there by default (#1794)
---
.../apache/cxf/cdi/JAXRSCdiResourceExtension.java | 27 +++++++++++++++-------
1 file changed, 19 insertions(+), 8 deletions(-)
diff --git
a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
index 75403e3a1e..6875afea6e 100644
---
a/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
+++
b/integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java
@@ -81,15 +81,16 @@ public class JAXRSCdiResourceExtension implements Extension
{
private boolean hasBus;
private Bus bus;
- private final Set< Bean< ? > > applicationBeans = new LinkedHashSet< Bean<
? > >();
- private final List< Bean< ? > > serviceBeans = new ArrayList< Bean< ? >
>();
- private final List< Bean< ? > > providerBeans = new ArrayList< Bean< ? >
>();
- private final List< Bean< ? extends Feature > > featureBeans = new
ArrayList< Bean< ? extends Feature > >();
+ private Set< Bean< ? > > applicationBeans = new LinkedHashSet< Bean< ? >
>();
+ private Set< Bean< ? > > serviceBeans = new HashSet< Bean< ? > >();
+ private Set< Bean< ? > > providerBeans = new HashSet< Bean< ? > >();
+ private Set< Bean< ? extends Feature > > featureBeans = new HashSet< Bean<
? extends Feature > >();
+ private Set< Type > contextTypes = new LinkedHashSet<>();
+
private final List< CreationalContext< ? > > disposableCreationalContexts =
new ArrayList<>();
private final List< Lifecycle > disposableLifecycles =
new ArrayList<>();
- private final Set< Type > contextTypes = new LinkedHashSet<>();
private final Collection< String > existingStandardClasses = new
HashSet<>();
@@ -261,6 +262,8 @@ public class JAXRSCdiResourceExtension implements Extension
{
factory.init();
}
}
+
+ cleanStartupData();
}
public void injectBus(@Observes final AfterBeanDiscovery event, final
BeanManager beanManager) {
@@ -294,6 +297,15 @@ public class JAXRSCdiResourceExtension implements
Extension {
t -> event.addBean(new ContextProducerBean(t,
!existingStandardClasses.contains(t.getTypeName()))));
}
+ private void cleanStartupData() { // enable gc
+ Stream.of(serviceBeans, providerBeans, featureBeans, applicationBeans,
contextTypes).forEach(Collection::clear);
+ serviceBeans = null;
+ providerBeans = null;
+ featureBeans = null;
+ applicationBeans = null;
+ contextTypes = null;
+ }
+
/**
* Registers created CreationalContext instances for disposal
*/
@@ -472,8 +484,7 @@ public class JAXRSCdiResourceExtension implements Extension
{
*/
private List< Object > loadBeans(final BeanManager beanManager,
Collection<Class<?>> limitedClasses,
Collection<Bean<?>> beans) {
- // Use set to account for singletons and application scoped beans
- final Set< Object > instances = new LinkedHashSet<>();
+ final List< Object > instances = new ArrayList<>();
for (final Bean< ? > bean: beans) {
if (limitedClasses.isEmpty() ||
limitedClasses.contains(bean.getBeanClass())) {
@@ -487,7 +498,7 @@ public class JAXRSCdiResourceExtension implements Extension
{
}
}
- return new ArrayList<>(instances);
+ return instances;
}
/**