Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1163040

Summary: CDI uses default EmbeddedCacheManager producer from infinispan-cdi.jar instead of custom one
Product: [JBoss] JBoss Data Grid 6 Reporter: Vitalii Chepeliuk <vchepeli>
Component: InfinispanAssignee: Vitalii Chepeliuk <vchepeli>
Status: CLOSED CURRENTRELEASE QA Contact: Martin Gencur <mgencur>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.4.0CC: jdg-bugs, rmarwaha, slaskawi, vjuranek
Target Milestone: ER1   
Target Release: 6.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-23 12:24:45 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Add cdi-reproducer.zip none

Description Vitalii Chepeliuk 2014-11-12 09:37:29 UTC
See description of ISPN-4971

Comment 2 Vitalii Chepeliuk 2014-11-12 09:47:06 UTC
Created attachment 956658 [details]
Add cdi-reproducer.zip

Inside of reproducer you can find interceptor tests which fail when wrong EmbeddedCacheManager is used.

Comment 3 Vojtech Juranek 2014-11-14 10:06:07 UTC
btw: there's already BZ #1142474, older, but less informative. I'll pass to the asignee which one should be closed as duplicate:-)

Comment 4 JBoss JIRA Server 2015-01-19 09:25:52 UTC
Sebastian Łaskawiec <slaskawi> updated the status of jira ISPN-4971 to Closed

Comment 5 Sebastian Łaskawiec 2015-01-19 09:29:47 UTC
*** Bug 1142474 has been marked as a duplicate of this bug. ***

Comment 6 Sebastian Łaskawiec 2015-01-19 09:31:11 UTC
When deploying this code on App Server, there is a race condition in DefaultEmbeddedCacheManagerProducer#getDefaultEmbeddedCacheManager. Those EmbeddedCache producers are deployed in separate deployment units (the former is in CDI Extension and the latter in WAR). On the other hand this approach works fine in CDI module, mainly because there is only one deployment unit there.

Since @OverrideDefault is deprecated, I suggest modifying test code like this:
public class EmbeddedCacheManagerProducer {
 
   @Produces
   @ApplicationScoped
   public EmbeddedCacheManager getDefaultEmbeddedCacheManager(Configuration defaultConfiguration) {
      GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().globalJmxStatistics().allowDuplicateDomains(true).build();
 
      ConfigurationBuilder builder = new ConfigurationBuilder();
      builder.read(defaultConfiguration);
 
      return new DefaultCacheManager(globalConfiguration, builder.build());
   }
 
   private void stopCacheManager(@Disposes EmbeddedCacheManager defaultEmbeddedCacheManager) {
      defaultEmbeddedCacheManager.stop();
   }
}

Note that @OverrideDefault is gone and there is no need to check whether there is an instance of EmbeddedCache (Instance<EmbeddedCacheManager>).

The correct implementation is mentioned in Infinispan's manual: http://infinispan.org/docs/7.1.x/user_guide/user_guide.html#_override_the_default_embedded_cache_manager_and_configuration

Comment 7 Vitalii Chepeliuk 2015-03-31 09:02:12 UTC
PR sent: https://github.com/infinispan/jdg/pull/601