[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=1649#comment-1649 ] Dennis Kieselhorst commented on CXF-7742: - [~romain.manni-bucau] [~reta] PR has been merged, can we resolve this issue? > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > Fix For: 3.2.5 > > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16489962#comment-16489962 ] ASF GitHub Bot commented on CXF-7742: - reta commented on issue #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#issuecomment-391892148 Done, thanks a lot for fixing that, @rmannibucau ! This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16489960#comment-16489960 ] ASF GitHub Bot commented on CXF-7742: - reta closed pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418 This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): 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 d2b76dbd5cd..9c5b48c9e31 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 @@ -29,6 +29,7 @@ import java.util.ServiceLoader; import java.util.Set; +import javax.enterprise.context.Dependent; import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.event.Observes; import javax.enterprise.inject.spi.AfterBeanDiscovery; @@ -45,6 +46,7 @@ import javax.enterprise.inject.spi.ProcessProducerField; import javax.enterprise.inject.spi.ProcessProducerMethod; import javax.enterprise.inject.spi.WithAnnotations; +import javax.inject.Singleton; import javax.ws.rs.ApplicationPath; import javax.ws.rs.Path; import javax.ws.rs.core.Application; @@ -60,6 +62,7 @@ import org.apache.cxf.jaxrs.JAXRSServerFactoryBean; import org.apache.cxf.jaxrs.ext.ContextClassProvider; import org.apache.cxf.jaxrs.ext.JAXRSServerFactoryCustomizationExtension; +import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; import org.apache.cxf.jaxrs.provider.ServerConfigurableFactory; import org.apache.cxf.jaxrs.utils.InjectionUtils; import org.apache.cxf.jaxrs.utils.JAXRSServerFactoryCustomizationUtils; @@ -82,6 +85,8 @@ private final List< Bean< ? extends Feature > > featureBeans = new ArrayList< Bean< ? extends Feature > >(); private final List< CreationalContext< ? > > disposableCreationalContexts = new ArrayList< CreationalContext< ? > >(); +private final List< Lifecycle > disposableLifecycles = +new ArrayList<>(); private final Set< Type > contextTypes = new LinkedHashSet<>(); private final Collection< String > existingStandardClasses = new HashSet<>(); @@ -93,7 +98,7 @@ private static class ClassifiedClasses { private List< Object > providers = new ArrayList<>(); private List< Feature > features = new ArrayList<>(); -private List< CdiResourceProvider > resourceProviders = new ArrayList<>(); +private List resourceProviders = new ArrayList<>(); public void addProviders(final Collection< Object > others) { this.providers.addAll(others); @@ -103,7 +108,7 @@ public void addFeatures(final Collection< Feature > others) { this.features.addAll(others); } -public void addResourceProvider(final CdiResourceProvider other) { +public void addResourceProvider(final ResourceProvider other) { this.resourceProviders.add(other); } @@ -115,7 +120,7 @@ public void addResourceProvider(final CdiResourceProvider other) { return features; } -public List getResourceProviders() { +public List getResourceProviders() { return resourceProviders; } } @@ -303,7 +308,11 @@ public void release(@Observes final BeforeShutdown event) { for (final CreationalContext disposableCreationalContext: disposableCreationalContexts) { disposableCreationalContext.release(); } +disposableCreationalContexts.clear(); } + +disposableLifecycles.forEach(Lifecycle::destroy); +disposableLifecycles.clear(); } private Class toClass(String name) { @@ -347,7 +356,7 @@ private JAXRSServerFactoryBean createFactoryInstance(final Application applicati instance.setProviders(classified.getProviders()); instance.getFeatures().addAll(classified.getFeatures()); -for (final CdiResourceProvider resourceProvider: classified.getResourceProviders()) { +for (final ResourceProvider resourceProvider: classified.getResourceProviders()) { instance.setResourceProvider(resourceProvider.getResourceClass(), resourceProvider); } @@ -372,7 +381,28 @@ private ClassifiedClasses classes2singletons(final Application application, fina for (final Bean< ? > bean: serviceBeans) { if (classes.contains(bean.getBeanClass())) { -classified.addResourceProvider(new CdiResourceProvider(beanManager, bean)); +//
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16489906#comment-16489906 ] ASF GitHub Bot commented on CXF-7742: - rmannibucau commented on issue #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#issuecomment-391883148 @reta if possible, sure. Thanks a lot. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16489859#comment-16489859 ] ASF GitHub Bot commented on CXF-7742: - reta commented on issue #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#issuecomment-391874736 @rmannibucau Looks good to me, do you want me to merge? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16489464#comment-16489464 ] ASF GitHub Bot commented on CXF-7742: - rmannibucau commented on issue #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#issuecomment-391800594 Anything preventing a merge or are we good to go like that? (No pression, just checking if something is expected from my side) This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16488118#comment-16488118 ] ASF GitHub Bot commented on CXF-7742: - reta commented on a change in pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#discussion_r190417582 ## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/SingletonResourceProvider.java ## @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.cdi; + +import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; +import org.apache.cxf.message.Message; + +public class SingletonResourceProvider implements ResourceProvider { +private final Class clazz; +private Object instance; + +SingletonResourceProvider(final Lifecycle lifecycle, final Class clazz) { +this.instance = lifecycle.create(); Review comment: :+1: This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16487179#comment-16487179 ] ASF GitHub Bot commented on CXF-7742: - rmannibucau commented on a change in pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#discussion_r190229459 ## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/SingletonResourceProvider.java ## @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.cdi; + +import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; +import org.apache.cxf.message.Message; + +public class SingletonResourceProvider implements ResourceProvider { +private final Class clazz; +private Object instance; + +SingletonResourceProvider(final Lifecycle lifecycle, final Class clazz) { +this.instance = lifecycle.create(); Review comment: Well for all normal scoped beans it is still lazy thanks to CDI proxies and for @Singleton/@Dependent it becomes eager but it is ok from a business perspective + the extension already does it in several cases so not a big deal IMHO. This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16487062#comment-16487062 ] ASF GitHub Bot commented on CXF-7742: - reta commented on issue #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#issuecomment-391301940 @rmannibucau Looks better like that, with providers split between different classes This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16487060#comment-16487060 ] ASF GitHub Bot commented on CXF-7742: - reta commented on a change in pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#discussion_r190199396 ## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/SingletonResourceProvider.java ## @@ -0,0 +1,52 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.cxf.cdi; + +import org.apache.cxf.jaxrs.lifecycle.ResourceProvider; +import org.apache.cxf.message.Message; + +public class SingletonResourceProvider implements ResourceProvider { +private final Class clazz; +private Object instance; + +SingletonResourceProvider(final Lifecycle lifecycle, final Class clazz) { +this.instance = lifecycle.create(); Review comment: Should we create instance proactively here? It is simpler like that but it may not be needed (in theory, at least) This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16486847#comment-16486847 ] ASF GitHub Bot commented on CXF-7742: - rmannibucau commented on issue #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#issuecomment-391248360 @reta I updated the PR, I split the provider for singletons and per request handling, it looks easier to me to follow what is done and avoid to be tempted to be back to something not thread safe, I added a test on the scope handling too This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16486798#comment-16486798 ] ASF GitHub Bot commented on CXF-7742: - rmannibucau commented on a change in pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#discussion_r190137393 ## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java ## @@ -372,7 +379,14 @@ private ClassifiedClasses classes2singletons(final Application application, fina for (final Bean< ? > bean: serviceBeans) { if (classes.contains(bean.getBeanClass())) { -classified.addResourceProvider(new CdiResourceProvider(beanManager, bean)); +final CdiResourceProvider provider = new CdiResourceProvider(beanManager, bean); +// if not a singleton we manage it per request +// if @Singleton the container handles it +// so we only need this case here +if (provider.isSingleton() && Dependent.class == bean.getScope()) { +disposableResourceProviders.add(provider); Review comment: Oh good catch, copied the pattern of disposableCreationalContexts but actually we don't need that for that list which is just used in the context of the extension so thread safe, will clean up This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16486491#comment-16486491 ] ASF GitHub Bot commented on CXF-7742: - reta commented on issue #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#issuecomment-391178510 @rmannibucau Looks good, a few minor comments, I am wondering if it's worth creating a test case for different beans backed by resource providers? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16486488#comment-16486488 ] ASF GitHub Bot commented on CXF-7742: - reta commented on issue #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#issuecomment-391178510 @rmannibucau Looks good, a few minor comments, I am wondering if it worth creating a test case for different resource providers? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16486489#comment-16486489 ] ASF GitHub Bot commented on CXF-7742: - reta commented on issue #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#issuecomment-391178510 @rmannibucau Looks good, a few minor comments, I am wondering if it worth creating a test case for different beans backed by resource providers? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16485776#comment-16485776 ] ASF GitHub Bot commented on CXF-7742: - reta commented on a change in pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#discussion_r190088307 ## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java ## @@ -372,7 +379,14 @@ private ClassifiedClasses classes2singletons(final Application application, fina for (final Bean< ? > bean: serviceBeans) { if (classes.contains(bean.getBeanClass())) { -classified.addResourceProvider(new CdiResourceProvider(beanManager, bean)); +final CdiResourceProvider provider = new CdiResourceProvider(beanManager, bean); +// if not a singleton we manage it per request +// if @Singleton the container handles it +// so we only need this case here +if (provider.isSingleton() && Dependent.class == bean.getScope()) { +disposableResourceProviders.add(provider); Review comment: ``` synchronized (disposableResourceProviders) { disposableResourceProviders.add(provider); } ``` ? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16485775#comment-16485775 ] ASF GitHub Bot commented on CXF-7742: - reta commented on a change in pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#discussion_r190088307 ## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java ## @@ -372,7 +379,14 @@ private ClassifiedClasses classes2singletons(final Application application, fina for (final Bean< ? > bean: serviceBeans) { if (classes.contains(bean.getBeanClass())) { -classified.addResourceProvider(new CdiResourceProvider(beanManager, bean)); +final CdiResourceProvider provider = new CdiResourceProvider(beanManager, bean); +// if not a singleton we manage it per request +// if @Singleton the container handles it +// so we only need this case here +if (provider.isSingleton() && Dependent.class == bean.getScope()) { +disposableResourceProviders.add(provider); Review comment: ``` synchronized (disposableResourceProviders) { disposableResourceProviders.add(provider); } ``` This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16485774#comment-16485774 ] ASF GitHub Bot commented on CXF-7742: - reta commented on a change in pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#discussion_r190088232 ## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/JAXRSCdiResourceExtension.java ## @@ -303,6 +306,10 @@ public void release(@Observes final BeforeShutdown event) { for (final CreationalContext disposableCreationalContext: disposableCreationalContexts) { disposableCreationalContext.release(); } +disposableCreationalContexts.clear(); +} +synchronized (disposableResourceProviders) { +disposableResourceProviders.forEach(p -> p.getLifecycle().destroy()); Review comment: `disposableResourceProviders.clear()`? This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16484728#comment-16484728 ] ASF GitHub Bot commented on CXF-7742: - reta commented on a change in pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418#discussion_r190079458 ## File path: integration/cdi/src/main/java/org/apache/cxf/cdi/CdiResourceProvider.java ## @@ -62,6 +95,37 @@ public void releaseInstance(Message m, Object o) { @Override public boolean isSingleton() { -return !beanManager.isNormalScope(bean.getScope()); +return singleton; +} + +// warn: several impls use @Dependent == request so we should probably add a flag +private boolean isConsideredSingleton() { +return Singleton.class == bean.getScope() || Dependent.class == bean.getScope(); +} + +public abstract static class Lifecycle { +BeanManager beanManager; +Bean bean; +Object instance; Review comment: The `instance` could be removed, right? Since `Lifecycle` for the singleton re-declares it . This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)
[jira] [Commented] (CXF-7742) CdiResourceProvider is not thread safe
[ https://issues.apache.org/jira/browse/CXF-7742?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16483746#comment-16483746 ] ASF GitHub Bot commented on CXF-7742: - rmannibucau opened a new pull request #418: CXF-7742 handling scopes in CdiResourceProvider URL: https://github.com/apache/cxf/pull/418 This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org > CdiResourceProvider is not thread safe > -- > > Key: CXF-7742 > URL: https://issues.apache.org/jira/browse/CXF-7742 > Project: CXF > Issue Type: Bug >Affects Versions: 3.2.4 >Reporter: Romain Manni-Bucau >Priority: Major > -- This message was sent by Atlassian JIRA (v7.6.3#76005)