Refactor the clientCachePoolSocketConnectTimeoutBeanPostProcessor bean definition to be conditional on the presence of the setSocketConnectTimeout(:int) method on the ClientCacheFactoryBean class.
This commit is contained in:
@@ -19,6 +19,7 @@ package org.springframework.data.gemfire.tests.integration.config;
|
||||
import static org.springframework.data.gemfire.util.CollectionUtils.nullSafeMap;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
@@ -39,7 +40,11 @@ import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Condition;
|
||||
import org.springframework.context.annotation.ConditionContext;
|
||||
import org.springframework.context.annotation.Conditional;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.type.AnnotatedTypeMetadata;
|
||||
import org.springframework.data.gemfire.client.ClientCacheFactoryBean;
|
||||
import org.springframework.data.gemfire.client.ClientRegionFactoryBean;
|
||||
import org.springframework.data.gemfire.client.ClientRegionShortcutWrapper;
|
||||
@@ -48,6 +53,7 @@ import org.springframework.data.gemfire.config.xml.GemfireConstants;
|
||||
import org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer;
|
||||
import org.springframework.data.gemfire.tests.integration.ClientServerIntegrationTestsSupport;
|
||||
import org.springframework.data.gemfire.tests.util.ObjectUtils;
|
||||
import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -129,6 +135,7 @@ public class SubscriptionEnabledClientServerIntegrationTestsConfiguration
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Conditional(ClientCacheFactoryBeanSetSocketConnectTimeoutPresentCondition.class)
|
||||
BeanPostProcessor clientCachePoolSocketConnectTimeoutBeanPostProcessor() {
|
||||
|
||||
return new BeanPostProcessor() {
|
||||
@@ -294,4 +301,15 @@ public class SubscriptionEnabledClientServerIntegrationTestsConfiguration
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static class ClientCacheFactoryBeanSetSocketConnectTimeoutPresentCondition implements Condition {
|
||||
|
||||
@Override @SuppressWarnings("all")
|
||||
public boolean matches(ConditionContext context, AnnotatedTypeMetadata metadata) {
|
||||
|
||||
return Arrays.stream(ArrayUtils.nullSafeArray(ClientCacheFactoryBean.class.getMethods(), Method.class))
|
||||
.map(Method::getName)
|
||||
.anyMatch("setSocketConnectTimeout"::equals);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user