Skip to content

Commit

Permalink
ISPN-10262 Deprecate custom interceptors configuration
Browse files Browse the repository at this point in the history
* Deprecate the custom interceptors configuration
* Warn at startup if custom interceptors are present
* Deprecate AdvancedCache.getAsyncInterceptorChain()
* Replace interceptors configuration with direct AsyncInterceptorChain
  manipulation in all the modules.
  • Loading branch information
danberindei authored and ryanemerson committed Jun 21, 2019
1 parent 3c0827f commit eef3f58
Show file tree
Hide file tree
Showing 25 changed files with 195 additions and 126 deletions.
7 changes: 2 additions & 5 deletions core/src/main/java/org/infinispan/AdvancedCache.java
Expand Up @@ -18,7 +18,6 @@
import org.infinispan.commons.api.TransactionalCache; import org.infinispan.commons.api.TransactionalCache;
import org.infinispan.commons.dataconversion.Encoder; import org.infinispan.commons.dataconversion.Encoder;
import org.infinispan.commons.dataconversion.Wrapper; import org.infinispan.commons.dataconversion.Wrapper;
import org.infinispan.commons.util.Experimental;
import org.infinispan.configuration.cache.ConfigurationBuilder; import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.cache.PartitionHandlingConfiguration; import org.infinispan.configuration.cache.PartitionHandlingConfiguration;
import org.infinispan.container.DataContainer; import org.infinispan.container.DataContainer;
Expand Down Expand Up @@ -191,12 +190,10 @@ default AdvancedCache<K, V> transform(Function<AdvancedCache<K, V>, ? extends Ad


/** /**
* Allows the modification of the interceptor chain. * Allows the modification of the interceptor chain.
* <p>
* Experimental: The ability to modify the interceptors at runtime may be removed in future versions.
* *
* @since 9.0 * @deprecated Since 10.0, will be removed without a replacement
*/ */
@Experimental @Deprecated
AsyncInterceptorChain getAsyncInterceptorChain(); AsyncInterceptorChain getAsyncInterceptorChain();


/** /**
Expand Down
Expand Up @@ -70,6 +70,10 @@ public void addInterceptor(CommandInterceptor i, int position) {
cache.getAsyncInterceptorChain().addInterceptor(i, position); cache.getAsyncInterceptorChain().addInterceptor(i, position);
} }


/**
* @deprecated Since 10.0, will be removed without a replacement
*/
@Deprecated
@Override @Override
public AsyncInterceptorChain getAsyncInterceptorChain() { public AsyncInterceptorChain getAsyncInterceptorChain() {
return cache.getAsyncInterceptorChain(); return cache.getAsyncInterceptorChain();
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/infinispan/cache/impl/CacheImpl.java
Expand Up @@ -1161,6 +1161,10 @@ public void addInterceptor(CommandInterceptor i, int position) {
invoker.addInterceptor(i, position); invoker.addInterceptor(i, position);
} }


/**
* @deprecated Since 10.0, will be removed without a replacement
*/
@Deprecated
@Override @Override
public AsyncInterceptorChain getAsyncInterceptorChain() { public AsyncInterceptorChain getAsyncInterceptorChain() {
return invoker; return invoker;
Expand Down
Expand Up @@ -1194,6 +1194,10 @@ public void addInterceptor(CommandInterceptor i, int position) {
throw log.interceptorStackNotSupported(); throw log.interceptorStackNotSupported();
} }


/**
* @deprecated Since 10.0, will be removed without a replacement
*/
@Deprecated
@Override @Override
public AsyncInterceptorChain getAsyncInterceptorChain() { public AsyncInterceptorChain getAsyncInterceptorChain() {
return EmptyAsyncInterceptorChain.INSTANCE; return EmptyAsyncInterceptorChain.INSTANCE;
Expand Down
Expand Up @@ -27,6 +27,10 @@ public ClusteringConfigurationBuilder clustering() {
return builder.clustering(); return builder.clustering();
} }


/**
* @deprecated Since 10.0, custom interceptors support will be removed and only modules will be able to define interceptors
*/
@Deprecated
@Override @Override
public CustomInterceptorsConfigurationBuilder customInterceptors() { public CustomInterceptorsConfigurationBuilder customInterceptors() {
return builder.customInterceptors(); return builder.customInterceptors();
Expand Down
@@ -1,5 +1,9 @@
package org.infinispan.configuration.cache; package org.infinispan.configuration.cache;


/**
* @deprecated Since 10.0, custom interceptors support will be removed and only modules will be able to define interceptors
*/
@Deprecated
public abstract class AbstractCustomInterceptorsConfigurationChildBuilder extends AbstractConfigurationChildBuilder { public abstract class AbstractCustomInterceptorsConfigurationChildBuilder extends AbstractConfigurationChildBuilder {


private final CustomInterceptorsConfigurationBuilder customInterceptorsBuilder; private final CustomInterceptorsConfigurationBuilder customInterceptorsBuilder;
Expand Down
Expand Up @@ -139,6 +139,10 @@ public ClusteringConfiguration clustering() {
return clusteringConfiguration; return clusteringConfiguration;
} }


/**
* @deprecated Since 10.0, custom interceptors support will be removed and only modules will be able to define interceptors
*/
@Deprecated
public CustomInterceptorsConfiguration customInterceptors() { public CustomInterceptorsConfiguration customInterceptors() {
return customInterceptorsConfiguration; return customInterceptorsConfiguration;
} }
Expand Down
Expand Up @@ -111,6 +111,10 @@ public ClusteringConfigurationBuilder clustering() {
return clustering; return clustering;
} }


/**
* @deprecated Since 10.0, custom interceptors support will be removed and only modules will be able to define interceptors
*/
@Deprecated
@Override @Override
public CustomInterceptorsConfigurationBuilder customInterceptors() { public CustomInterceptorsConfigurationBuilder customInterceptors() {
return customInterceptors; return customInterceptors;
Expand Down
Expand Up @@ -10,6 +10,10 @@ public interface ConfigurationChildBuilder {


ClusteringConfigurationBuilder clustering(); ClusteringConfigurationBuilder clustering();


/**
* @deprecated Since 10.0, custom interceptors support will be removed and only modules will be able to define interceptors
*/
@Deprecated
CustomInterceptorsConfigurationBuilder customInterceptors(); CustomInterceptorsConfigurationBuilder customInterceptors();


DataContainerConfigurationBuilder dataContainer(); DataContainerConfigurationBuilder dataContainer();
Expand Down
Expand Up @@ -15,7 +15,9 @@
* Configures custom interceptors to be added to the cache. * Configures custom interceptors to be added to the cache.
* *
* @author pmuir * @author pmuir
* @deprecated Since 10.0, custom interceptors support will be removed and only modules will be able to define interceptors
*/ */
@Deprecated
public class CustomInterceptorsConfiguration implements Matchable<CustomInterceptorsConfiguration>, ConfigurationInfo { public class CustomInterceptorsConfiguration implements Matchable<CustomInterceptorsConfiguration>, ConfigurationInfo {


static final ElementDefinition ELEMENT_DEFINITION = new DefaultElementDefinition(CUSTOM_INTERCEPTORS.getLocalName()); static final ElementDefinition ELEMENT_DEFINITION = new DefaultElementDefinition(CUSTOM_INTERCEPTORS.getLocalName());
Expand Down
Expand Up @@ -14,8 +14,9 @@
* Configures custom interceptors to be added to the cache. * Configures custom interceptors to be added to the cache.
* *
* @author pmuir * @author pmuir
* * @deprecated Since 10.0, custom interceptors support will be removed and only modules will be able to define interceptors
*/ */
@Deprecated
public class CustomInterceptorsConfigurationBuilder extends AbstractConfigurationChildBuilder implements Builder<CustomInterceptorsConfiguration>, ConfigurationBuilderInfo { public class CustomInterceptorsConfigurationBuilder extends AbstractConfigurationChildBuilder implements Builder<CustomInterceptorsConfiguration>, ConfigurationBuilderInfo {


private List<InterceptorConfigurationBuilder> interceptorBuilders = new LinkedList<>(); private List<InterceptorConfigurationBuilder> interceptorBuilders = new LinkedList<>();
Expand All @@ -26,7 +27,9 @@ public class CustomInterceptorsConfigurationBuilder extends AbstractConfiguratio


/** /**
* Adds a new custom interceptor definition, to be added to the cache when the cache is started. * Adds a new custom interceptor definition, to be added to the cache when the cache is started.
* @deprecated Since 10.0, custom interceptors support will be removed and only modules will be able to define interceptors
*/ */
@Deprecated
public InterceptorConfigurationBuilder addInterceptor() { public InterceptorConfigurationBuilder addInterceptor() {
InterceptorConfigurationBuilder builder = new InterceptorConfigurationBuilder(this); InterceptorConfigurationBuilder builder = new InterceptorConfigurationBuilder(this);
this.interceptorBuilders.add(builder); this.interceptorBuilders.add(builder);
Expand Down
Expand Up @@ -28,7 +28,10 @@


/** /**
* This builder defines details of a specific custom interceptor. * This builder defines details of a specific custom interceptor.
*
* @deprecated Since 10.0, custom interceptors support will be removed and only modules will be able to define interceptors
*/ */
@Deprecated
public class InterceptorConfigurationBuilder extends AbstractCustomInterceptorsConfigurationChildBuilder implements Builder<InterceptorConfiguration>, ConfigurationBuilderInfo { public class InterceptorConfigurationBuilder extends AbstractCustomInterceptorsConfigurationChildBuilder implements Builder<InterceptorConfiguration>, ConfigurationBuilderInfo {
private static final Log log = LogFactory.getLog(InterceptorConfigurationBuilder.class); private static final Log log = LogFactory.getLog(InterceptorConfigurationBuilder.class);
private final AttributeSet attributes; private final AttributeSet attributes;
Expand Down
Expand Up @@ -1396,6 +1396,7 @@ protected void parseCacheElement(XMLExtendedStreamReader reader, Element element
break; break;
} }
case CUSTOM_INTERCEPTORS: { case CUSTOM_INTERCEPTORS: {
log.customInterceptorsDeprecated();
this.parseCustomInterceptors(reader, holder); this.parseCustomInterceptors(reader, holder);
break; break;
} }
Expand Down
Expand Up @@ -248,6 +248,10 @@ public void addInterceptor(CommandInterceptor i, int position) {
delegate.addInterceptor(i, position); delegate.addInterceptor(i, position);
} }


/**
* @deprecated Since 10.0, will be removed without a replacement
*/
@Deprecated
@Override @Override
public AsyncInterceptorChain getAsyncInterceptorChain() { public AsyncInterceptorChain getAsyncInterceptorChain() {
authzManager.checkPermission(subject, AuthorizationPermission.ADMIN); authzManager.checkPermission(subject, AuthorizationPermission.ADMIN);
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/infinispan/util/logging/Log.java
Expand Up @@ -1867,4 +1867,8 @@ CacheConfigurationException offHeapMemoryEvictionSizeNotLargeEnoughForAddresses(


@Message(value = "Invalidation mode only supports when-split=ALLOW_READ_WRITES", id = 550) @Message(value = "Invalidation mode only supports when-split=ALLOW_READ_WRITES", id = 550)
CacheConfigurationException invalidationPartitionHandlingNotSuported(); CacheConfigurationException invalidationPartitionHandlingNotSuported();

@LogMessage(level = WARN)
@Message(value = "The custom interceptors configuration has been deprecated and will be ignored in the future", id = 551)
void customInterceptorsDeprecated();
} }
4 changes: 3 additions & 1 deletion core/src/main/resources/schema/infinispan-config-10.0.xsd
Expand Up @@ -850,7 +850,8 @@
</xs:element> </xs:element>
<xs:element name="custom-interceptors" type="tns:custom-interceptors" minOccurs="0"> <xs:element name="custom-interceptors" type="tns:custom-interceptors" minOccurs="0">
<xs:annotation> <xs:annotation>
<xs:documentation>Configures custom interceptors to be added to the cache.</xs:documentation> <xs:documentation>Deprecated since 10.0, will be removed without a replacement.
Configures custom interceptors to be added to the cache.</xs:documentation>
</xs:annotation> </xs:annotation>
</xs:element> </xs:element>
<xs:element name="security" type="tns:cache-security" minOccurs="0"> <xs:element name="security" type="tns:cache-security" minOccurs="0">
Expand Down Expand Up @@ -1195,6 +1196,7 @@
<xs:complexType name="custom-interceptors"> <xs:complexType name="custom-interceptors">
<xs:sequence> <xs:sequence>
<xs:element name="interceptor" minOccurs="0" maxOccurs="unbounded"> <xs:element name="interceptor" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>Deprecated since 10.0, will be removed without a replacement.</xs:annotation>
<xs:complexType> <xs:complexType>
<xs:sequence> <xs:sequence>
<xs:element name="property" type="tns:property" minOccurs="0"/> <xs:element name="property" type="tns:property" minOccurs="0"/>
Expand Down
Expand Up @@ -293,6 +293,10 @@ public void addInterceptor(CommandInterceptor i, int position) {
cache.addInterceptor(i, position); cache.addInterceptor(i, position);
} }


/**
* @deprecated Since 10.0, will be removed without a replacement
*/
@Deprecated
@Override @Override
public AsyncInterceptorChain getAsyncInterceptorChain() { public AsyncInterceptorChain getAsyncInterceptorChain() {
return cache.getAsyncInterceptorChain(); return cache.getAsyncInterceptorChain();
Expand Down
4 changes: 4 additions & 0 deletions core/src/test/java/org/infinispan/test/TestingUtil.java
Expand Up @@ -1027,6 +1027,10 @@ public static PersistenceMarshaller extractPersistenceMarshaller(EmbeddedCacheMa
return cm.getGlobalComponentRegistry().getComponent(PersistenceMarshaller.class, KnownComponentNames.PERSISTENCE_MARSHALLER); return cm.getGlobalComponentRegistry().getComponent(PersistenceMarshaller.class, KnownComponentNames.PERSISTENCE_MARSHALLER);
} }


public static AsyncInterceptorChain extractInterceptorChain(Cache cache) {
return extractComponent(cache, AsyncInterceptorChain.class);
}

/** /**
* Add a hook to cache startup sequence that will allow to replace existing component with a mock. * Add a hook to cache startup sequence that will allow to replace existing component with a mock.
* @param cacheContainer * @param cacheContainer
Expand Down
Expand Up @@ -30,10 +30,12 @@
import org.infinispan.counter.impl.metadata.ConfigurationMetadata; import org.infinispan.counter.impl.metadata.ConfigurationMetadata;
import org.infinispan.counter.impl.persistence.PersistenceContextInitializerImpl; import org.infinispan.counter.impl.persistence.PersistenceContextInitializerImpl;
import org.infinispan.counter.logging.Log; import org.infinispan.counter.logging.Log;
import org.infinispan.factories.ComponentRegistry;
import org.infinispan.factories.GlobalComponentRegistry; import org.infinispan.factories.GlobalComponentRegistry;
import org.infinispan.factories.annotations.InfinispanModule;
import org.infinispan.factories.KnownComponentNames; import org.infinispan.factories.KnownComponentNames;
import org.infinispan.factories.annotations.InfinispanModule;
import org.infinispan.factories.impl.BasicComponentRegistry; import org.infinispan.factories.impl.BasicComponentRegistry;
import org.infinispan.interceptors.AsyncInterceptorChain;
import org.infinispan.interceptors.impl.EntryWrappingInterceptor; import org.infinispan.interceptors.impl.EntryWrappingInterceptor;
import org.infinispan.jmx.CacheManagerJmxRegistration; import org.infinispan.jmx.CacheManagerJmxRegistration;
import org.infinispan.lifecycle.ModuleLifecycle; import org.infinispan.lifecycle.ModuleLifecycle;
Expand Down Expand Up @@ -66,9 +68,7 @@ private static Configuration createCounterCacheConfiguration(CounterManagerConfi
.partitionHandling().whenSplit(config.reliability() == Reliability.CONSISTENT ? .partitionHandling().whenSplit(config.reliability() == Reliability.CONSISTENT ?
PartitionHandling.DENY_READ_WRITES : PartitionHandling.DENY_READ_WRITES :
PartitionHandling.ALLOW_READ_WRITES) PartitionHandling.ALLOW_READ_WRITES)
.transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL) .transaction().transactionMode(TransactionMode.NON_TRANSACTIONAL);
.customInterceptors().addInterceptor().after(EntryWrappingInterceptor.class)
.interceptor(new CounterInterceptor());
return builder.build(); return builder.build();
} }


Expand All @@ -84,9 +84,8 @@ private static void addAdvancedExternalizer(Map<Integer, AdvancedExternalizer<?>
map.put(ext.getId(), ext); map.put(ext.getId(), ext);
} }


private static CounterManagerConfiguration extractConfiguration(GlobalComponentRegistry globalComponentRegistry) { private static CounterManagerConfiguration extractConfiguration(GlobalConfiguration globalConfiguration) {
CounterManagerConfiguration config = globalComponentRegistry.getGlobalConfiguration() CounterManagerConfiguration config = globalConfiguration.module(CounterManagerConfiguration.class);
.module(CounterManagerConfiguration.class);
return config == null ? CounterManagerConfigurationBuilder.defaultConfiguration() : config; return config == null ? CounterManagerConfigurationBuilder.defaultConfiguration() : config;
} }


Expand Down Expand Up @@ -136,7 +135,7 @@ public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguratio
PersistenceMarshaller persistenceMarshaller = bcr.getComponent(KnownComponentNames.PERSISTENCE_MARSHALLER, PersistenceMarshaller.class).wired(); PersistenceMarshaller persistenceMarshaller = bcr.getComponent(KnownComponentNames.PERSISTENCE_MARSHALLER, PersistenceMarshaller.class).wired();
persistenceMarshaller.register(new PersistenceContextInitializerImpl()); persistenceMarshaller.register(new PersistenceContextInitializerImpl());


CounterManagerConfiguration counterManagerConfiguration = extractConfiguration(gcr); CounterManagerConfiguration counterManagerConfiguration = extractConfiguration(globalConfiguration);
if (gcr.getGlobalConfiguration().isClustered()) { if (gcr.getGlobalConfiguration().isClustered()) {
//only attempts to create the caches if the cache manager is clustered. //only attempts to create the caches if the cache manager is clustered.
registerCounterCache(internalCacheRegistry, counterManagerConfiguration); registerCounterCache(internalCacheRegistry, counterManagerConfiguration);
Expand All @@ -146,4 +145,16 @@ public void cacheManagerStarting(GlobalComponentRegistry gcr, GlobalConfiguratio
} }
registerCounterManager(cacheManager, bcr); registerCounterManager(cacheManager, bcr);
} }

@Override
public void cacheStarting(ComponentRegistry cr, Configuration configuration, String cacheName) {
if (COUNTER_CACHE_NAME.equals(cacheName) && configuration.clustering().cacheMode().isClustered()) {
BasicComponentRegistry bcr = cr.getComponent(BasicComponentRegistry.class);
CounterInterceptor counterInterceptor = new CounterInterceptor();
bcr.registerComponent(CounterInterceptor.class, counterInterceptor, true);
bcr.addDynamicDependency(AsyncInterceptorChain.class.getName(), CounterInterceptor.class.getName());
bcr.getComponent(AsyncInterceptorChain.class).wired()
.addInterceptorAfter(counterInterceptor, EntryWrappingInterceptor.class);
}
}
} }
Expand Up @@ -31,10 +31,7 @@
import org.infinispan.commons.util.AggregatedClassLoader; import org.infinispan.commons.util.AggregatedClassLoader;
import org.infinispan.commons.util.ServiceFinder; import org.infinispan.commons.util.ServiceFinder;
import org.infinispan.configuration.cache.Configuration; import org.infinispan.configuration.cache.Configuration;
import org.infinispan.configuration.cache.ConfigurationBuilder;
import org.infinispan.configuration.cache.CustomInterceptorsConfigurationBuilder;
import org.infinispan.configuration.cache.IndexingConfiguration; import org.infinispan.configuration.cache.IndexingConfiguration;
import org.infinispan.configuration.cache.InterceptorConfiguration;
import org.infinispan.configuration.global.GlobalConfiguration; import org.infinispan.configuration.global.GlobalConfiguration;
import org.infinispan.configuration.global.GlobalJmxStatisticsConfiguration; import org.infinispan.configuration.global.GlobalJmxStatisticsConfiguration;
import org.infinispan.factories.ComponentRegistry; import org.infinispan.factories.ComponentRegistry;
Expand Down Expand Up @@ -191,12 +188,8 @@ private void createQueryInterceptorIfNeeded(BasicComponentRegistry cr, Configura
keyTransformationHandler.registerTransformer(kt.getKey(), (Class<? extends Transformer>) kt.getValue()); keyTransformationHandler.registerTransformer(kt.getKey(), (Class<? extends Transformer>) kt.getValue());
} }


// Interceptor registration not needed, core configuration handling
// already does it for all custom interceptors - UNLESS the InterceptorChain already exists in the component registry!
AsyncInterceptorChain ic = cr.getComponent(AsyncInterceptorChain.class).wired(); AsyncInterceptorChain ic = cr.getComponent(AsyncInterceptorChain.class).wired();


ConfigurationBuilder builder = new ConfigurationBuilder().read(cfg);

EntryWrappingInterceptor wrappingInterceptor = ic.findInterceptorExtending(EntryWrappingInterceptor.class); EntryWrappingInterceptor wrappingInterceptor = ic.findInterceptorExtending(EntryWrappingInterceptor.class);
AsyncInterceptor lastLoadingInterceptor = ic.findInterceptorExtending(CacheLoaderInterceptor.class); AsyncInterceptor lastLoadingInterceptor = ic.findInterceptorExtending(CacheLoaderInterceptor.class);
if (lastLoadingInterceptor == null) { if (lastLoadingInterceptor == null) {
Expand All @@ -207,22 +200,12 @@ private void createQueryInterceptorIfNeeded(BasicComponentRegistry cr, Configura
cr.registerComponent(QueryInterceptor.class, queryInterceptor, true); cr.registerComponent(QueryInterceptor.class, queryInterceptor, true);
cr.addDynamicDependency(AsyncInterceptorChain.class.getName(), QueryInterceptor.class.getName()); cr.addDynamicDependency(AsyncInterceptorChain.class.getName(), QueryInterceptor.class.getName());


// add the interceptor to the configuration also
builder.customInterceptors().addInterceptor()
.interceptor(queryInterceptor).after(lastLoadingInterceptor.getClass());

if (cfg.transaction().transactionMode().isTransactional()) { if (cfg.transaction().transactionMode().isTransactional()) {
TxQueryInterceptor txQueryInterceptor = new TxQueryInterceptor(txOldValues, queryInterceptor); TxQueryInterceptor txQueryInterceptor = new TxQueryInterceptor(txOldValues, queryInterceptor);
ic.addInterceptorBefore(txQueryInterceptor, wrappingInterceptor.getClass()); ic.addInterceptorBefore(txQueryInterceptor, wrappingInterceptor.getClass());
cr.registerComponent(TxQueryInterceptor.class, txQueryInterceptor, true); cr.registerComponent(TxQueryInterceptor.class, txQueryInterceptor, true);
cr.addDynamicDependency(AsyncInterceptorChain.class.getName(), TxQueryInterceptor.class.getName()); cr.addDynamicDependency(AsyncInterceptorChain.class.getName(), TxQueryInterceptor.class.getName());

// add the interceptor to the configuration also
builder.customInterceptors().addInterceptor()
.interceptor(txQueryInterceptor).before(wrappingInterceptor.getClass());
} }

cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors());
} }


@Override @Override
Expand Down Expand Up @@ -433,21 +416,6 @@ private void unregisterQueryMBeans(ComponentRegistry cr, String cacheName) {


@Override @Override
public void cacheStopped(ComponentRegistry cr, String cacheName) { public void cacheStopped(ComponentRegistry cr, String cacheName) {
Configuration cfg = cr.getComponent(Configuration.class);
removeQueryInterceptorFromConfiguration(cfg);
}

private void removeQueryInterceptorFromConfiguration(Configuration cfg) {
ConfigurationBuilder builder = new ConfigurationBuilder();
CustomInterceptorsConfigurationBuilder customInterceptorsBuilder = builder.customInterceptors();

for (InterceptorConfiguration interceptorConfig : cfg.customInterceptors().interceptors()) {
if (!(interceptorConfig.asyncInterceptor() instanceof QueryInterceptor)) {
customInterceptorsBuilder.addInterceptor().read(interceptorConfig);
}
}

cfg.customInterceptors().interceptors(builder.build().customInterceptors().interceptors());
} }


@Override @Override
Expand Down
@@ -1,7 +1,9 @@
package org.infinispan.query.blackbox; package org.infinispan.query.blackbox;


import static org.infinispan.test.TestingUtil.extractInterceptorChain;
import static org.infinispan.test.TestingUtil.withCacheManager; import static org.infinispan.test.TestingUtil.withCacheManager;
import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue; import static org.testng.AssertJUnit.assertTrue;
import static org.testng.AssertJUnit.fail; import static org.testng.AssertJUnit.fail;


Expand All @@ -18,6 +20,7 @@
import org.infinispan.query.CacheQuery; import org.infinispan.query.CacheQuery;
import org.infinispan.query.Search; import org.infinispan.query.Search;
import org.infinispan.query.SearchManager; import org.infinispan.query.SearchManager;
import org.infinispan.query.backend.QueryInterceptor;
import org.infinispan.query.indexedembedded.Book; import org.infinispan.query.indexedembedded.Book;
import org.infinispan.test.AbstractInfinispanTest; import org.infinispan.test.AbstractInfinispanTest;
import org.infinispan.test.CacheManagerCallable; import org.infinispan.test.CacheManagerCallable;
Expand Down Expand Up @@ -49,13 +52,16 @@ private void indexedCacheRestart(boolean localOnly) {
.addIndexedEntity(Book.class) .addIndexedEntity(Book.class)
.addProperty("default.directory_provider", "local-heap") .addProperty("default.directory_provider", "local-heap")
.addProperty("lucene_version", "LUCENE_CURRENT"); .addProperty("lucene_version", "LUCENE_CURRENT");
// Test that the query module doesn't break user-configured custom interceptors
// Not needed since ISPN-10262, as the query module is no longer configuring any custom interceptors
final NoOpInterceptor noOpInterceptor = new NoOpInterceptor(); final NoOpInterceptor noOpInterceptor = new NoOpInterceptor();
builder.customInterceptors().addInterceptor().interceptor(noOpInterceptor).position(Position.FIRST); builder.customInterceptors().addInterceptor().interceptor(noOpInterceptor).position(Position.FIRST);


withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager(builder)) { withCacheManager(new CacheManagerCallable(TestCacheManagerFactory.createCacheManager(builder)) {
@Override @Override
public void call() { public void call() {
Cache<String, Book> cache = cm.getCache(); Cache<String, Book> cache = cm.getCache();
assertNotNull(extractInterceptorChain(cache).findInterceptorExtending(QueryInterceptor.class));
assertTrue(cache.isEmpty()); assertTrue(cache.isEmpty());
addABook(cache); addABook(cache);
assertFindBook(cache); assertFindBook(cache);
Expand All @@ -64,6 +70,7 @@ public void call() {
assertCacheHasCustomInterceptor(cache, noOpInterceptor); assertCacheHasCustomInterceptor(cache, noOpInterceptor);


cache.start(); cache.start();
assertNotNull(extractInterceptorChain(cache).findInterceptorExtending(QueryInterceptor.class));
assertTrue(cache.isEmpty()); assertTrue(cache.isEmpty());
//stopped cache lost all data, and in memory index is lost: re-store both //stopped cache lost all data, and in memory index is lost: re-store both
//(not needed with permanent indexes and caches using a cachestore) //(not needed with permanent indexes and caches using a cachestore)
Expand Down

0 comments on commit eef3f58

Please sign in to comment.