DATAREDIS-1233 - Polishing.
Update license header, use early return for if statements and guard tests against failure when running against a single node instance.
This commit is contained in:
@@ -26,6 +26,7 @@ import org.springframework.data.redis.connection.RedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.test.condition.EnabledOnRedisAvailable;
|
||||
import org.springframework.data.redis.test.condition.EnabledOnRedisSentinelAvailable;
|
||||
import org.springframework.data.redis.test.condition.EnabledOnRedisVersion;
|
||||
|
||||
@@ -35,6 +36,7 @@ import org.springframework.data.redis.test.condition.EnabledOnRedisVersion;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@EnabledOnRedisVersion("6.0")
|
||||
@EnabledOnRedisAvailable(6382)
|
||||
class JedisAclIntegrationTests {
|
||||
|
||||
@Test
|
||||
|
||||
@@ -29,10 +29,11 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.assertj.core.api.Assumptions;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceReactiveRedisConnection.ByteBufferCodec;
|
||||
import org.springframework.data.redis.test.condition.RedisDetector;
|
||||
import org.springframework.data.redis.test.extension.LettuceExtension;
|
||||
import org.springframework.data.redis.test.extension.parametrized.MethodSource;
|
||||
|
||||
@@ -151,11 +152,14 @@ public abstract class LettuceReactiveCommandsTestSupport {
|
||||
public void setUp() {
|
||||
|
||||
if (nativeConnectionProvider instanceof StandaloneConnectionProvider) {
|
||||
|
||||
nativeCommands = nativeConnectionProvider.getConnection(StatefulRedisConnection.class).sync();
|
||||
nativeBinaryCommands = nativeBinaryConnectionProvider.getConnection(StatefulRedisConnection.class).sync();
|
||||
this.connection = new LettuceReactiveRedisConnection(connectionProvider);
|
||||
|
||||
} else {
|
||||
|
||||
Assumptions.assumeThat(RedisDetector.isClusterAvailable()).isTrue();
|
||||
|
||||
ClusterConnectionProvider clusterConnectionProvider = (ClusterConnectionProvider) nativeConnectionProvider;
|
||||
nativeCommands = nativeConnectionProvider.getConnection(StatefulRedisClusterConnection.class).sync();
|
||||
nativeBinaryCommands = nativeBinaryConnectionProvider.getConnection(StatefulRedisClusterConnection.class).sync();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,19 +25,19 @@ import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.platform.commons.util.AnnotationUtils;
|
||||
|
||||
import org.springframework.data.redis.test.extension.LettuceExtension;
|
||||
|
||||
/**
|
||||
* {@link ExecutionCondition} for {@link EnabledOnCommandCondition @EnabledOnCommand}.
|
||||
*
|
||||
* @see EnabledOnCommandCondition
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
*/
|
||||
class EnabledOnCommandCondition implements ExecutionCondition {
|
||||
|
||||
private static final ConditionEvaluationResult ENABLED_BY_DEFAULT = enabled("@EnabledOnCommand is not present");
|
||||
private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace
|
||||
.create(RedisConditions.class);
|
||||
private static final ExtensionContext.Namespace NAMESPACE = ExtensionContext.Namespace.create(RedisConditions.class);
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@@ -45,24 +45,22 @@ class EnabledOnCommandCondition implements ExecutionCondition {
|
||||
|
||||
Optional<EnabledOnCommand> optional = AnnotationUtils.findAnnotation(context.getElement(), EnabledOnCommand.class);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
|
||||
String command = optional.get().value();
|
||||
|
||||
ExtensionContext.Store store = context.getStore(NAMESPACE);
|
||||
RedisConditions conditions = store.getOrComputeIfAbsent(RedisConditions.class, ignore -> {
|
||||
|
||||
StatefulRedisConnection connection = new LettuceExtension().resolve(context, StatefulRedisConnection.class);
|
||||
return RedisConditions.of(connection);
|
||||
}, RedisConditions.class);
|
||||
|
||||
boolean hasCommand = conditions.hasCommand(command);
|
||||
return hasCommand ? enabled("Enabled on command " + command)
|
||||
: disabled(
|
||||
"Disabled, command " + command + " not available on Redis version " + conditions.getRedisVersion());
|
||||
if (!optional.isPresent()) {
|
||||
return ENABLED_BY_DEFAULT;
|
||||
}
|
||||
|
||||
return ENABLED_BY_DEFAULT;
|
||||
String command = optional.get().value();
|
||||
|
||||
ExtensionContext.Store store = context.getStore(NAMESPACE);
|
||||
RedisConditions conditions = store.getOrComputeIfAbsent(RedisConditions.class, ignore -> {
|
||||
|
||||
StatefulRedisConnection connection = new LettuceExtension().resolve(context, StatefulRedisConnection.class);
|
||||
return RedisConditions.of(connection);
|
||||
}, RedisConditions.class);
|
||||
|
||||
boolean hasCommand = conditions.hasCommand(command);
|
||||
return hasCommand ? enabled("Enabled on command " + command)
|
||||
: disabled("Disabled, command " + command + " not available on Redis version " + conditions.getRedisVersion());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,13 +26,13 @@ import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.platform.commons.util.AnnotationUtils;
|
||||
|
||||
import org.springframework.data.redis.SettingsUtils;
|
||||
|
||||
/**
|
||||
* {@link ExecutionCondition} for {@link EnabledOnRedisAvailableCondition @EnabledOnRedisAvailable}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @see EnabledOnRedisAvailableCondition
|
||||
*/
|
||||
class EnabledOnRedisAvailableCondition implements ExecutionCondition {
|
||||
@@ -47,22 +47,21 @@ class EnabledOnRedisAvailableCondition implements ExecutionCondition {
|
||||
Optional<EnabledOnRedisAvailable> optional = AnnotationUtils.findAnnotation(context.getElement(),
|
||||
EnabledOnRedisAvailable.class);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
|
||||
EnabledOnRedisAvailable annotation = optional.get();
|
||||
|
||||
try (Socket socket = new Socket()) {
|
||||
socket.connect(new InetSocketAddress(SettingsUtils.getHost(), annotation.value()), 100);
|
||||
|
||||
return enabled(
|
||||
String.format("Connection successful to Redis at %s:%d", SettingsUtils.getHost(), annotation.value()));
|
||||
} catch (IOException e) {
|
||||
return disabled(
|
||||
String.format("Cannot connect to Redis at %s:%d (%s)", SettingsUtils.getHost(), annotation.value(), e));
|
||||
}
|
||||
if (!optional.isPresent()) {
|
||||
return ENABLED_BY_DEFAULT;
|
||||
}
|
||||
|
||||
return ENABLED_BY_DEFAULT;
|
||||
EnabledOnRedisAvailable annotation = optional.get();
|
||||
|
||||
try (Socket socket = new Socket()) {
|
||||
socket.connect(new InetSocketAddress(SettingsUtils.getHost(), annotation.value()), 100);
|
||||
|
||||
return enabled(
|
||||
String.format("Connection successful to Redis at %s:%d", SettingsUtils.getHost(), annotation.value()));
|
||||
} catch (IOException e) {
|
||||
return disabled(
|
||||
String.format("Cannot connect to Redis at %s:%d (%s)", SettingsUtils.getHost(), annotation.value(), e));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,13 +23,13 @@ import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.platform.commons.util.AnnotationUtils;
|
||||
|
||||
import org.springframework.data.redis.SettingsUtils;
|
||||
|
||||
/**
|
||||
* {@link ExecutionCondition} for {@link EnabledOnRedisClusterCondition @EnabledOnRedisClusterAvailable}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @see EnabledOnRedisClusterCondition
|
||||
*/
|
||||
class EnabledOnRedisClusterCondition implements ExecutionCondition {
|
||||
@@ -43,18 +43,17 @@ class EnabledOnRedisClusterCondition implements ExecutionCondition {
|
||||
Optional<EnabledOnRedisClusterAvailable> optional = AnnotationUtils.findAnnotation(context.getElement(),
|
||||
EnabledOnRedisClusterAvailable.class);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
if (!optional.isPresent()) {
|
||||
return ENABLED_BY_DEFAULT;
|
||||
}
|
||||
|
||||
if (RedisDetector.isClusterAvailable()) {
|
||||
return enabled(String.format("Connection successful to Redis Cluster at %s:%d", SettingsUtils.getHost(),
|
||||
SettingsUtils.getClusterPort()));
|
||||
}
|
||||
|
||||
return disabled(String.format("Cannot connect to Redis Cluster at %s:%d", SettingsUtils.getHost(),
|
||||
if (RedisDetector.isClusterAvailable()) {
|
||||
return enabled(String.format("Connection successful to Redis Cluster at %s:%d", SettingsUtils.getHost(),
|
||||
SettingsUtils.getClusterPort()));
|
||||
}
|
||||
|
||||
return ENABLED_BY_DEFAULT;
|
||||
return disabled(String.format("Cannot connect to Redis Cluster at %s:%d", SettingsUtils.getHost(),
|
||||
SettingsUtils.getClusterPort()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,13 +28,13 @@ import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.platform.commons.function.Try;
|
||||
import org.junit.platform.commons.util.AnnotationUtils;
|
||||
import org.junit.platform.commons.util.ReflectionUtils;
|
||||
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
|
||||
/**
|
||||
* {@link ExecutionCondition} for {@link EnabledOnRedisDriverCondition @EnabledOnRedisDriver}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @see EnabledOnRedisDriver
|
||||
*/
|
||||
class EnabledOnRedisDriverCondition implements ExecutionCondition {
|
||||
@@ -47,43 +47,42 @@ class EnabledOnRedisDriverCondition implements ExecutionCondition {
|
||||
Optional<EnabledOnRedisDriver> optional = AnnotationUtils.findAnnotation(context.getElement(),
|
||||
EnabledOnRedisDriver.class);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
|
||||
EnabledOnRedisDriver annotation = optional.get();
|
||||
Class<?> testClass = context.getRequiredTestClass();
|
||||
|
||||
List<Field> annotatedFields = AnnotationUtils.findAnnotatedFields(testClass,
|
||||
EnabledOnRedisDriver.DriverQualifier.class,
|
||||
it -> RedisConnectionFactory.class.isAssignableFrom(it.getType()));
|
||||
|
||||
if (annotatedFields.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
"@WithRedisDriver requires a field of type RedisConnectionFactory annotated with @DriverQualifier!");
|
||||
}
|
||||
|
||||
for (Field field : annotatedFields) {
|
||||
Try<Object> fieldValue = ReflectionUtils.tryToReadFieldValue(field, context.getRequiredTestInstance());
|
||||
|
||||
RedisConnectionFactory value = (RedisConnectionFactory) fieldValue
|
||||
.getOrThrow(e -> new IllegalStateException("Cannot read field " + field, e));
|
||||
|
||||
boolean foundMatch = false;
|
||||
for (RedisDriver redisDriver : annotation.value()) {
|
||||
if (redisDriver.matches(value)) {
|
||||
foundMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMatch) {
|
||||
return disabled(String.format("Driver %s not supported. Supported driver(s): %s",
|
||||
value, Arrays.toString(annotation.value())));
|
||||
}
|
||||
}
|
||||
|
||||
return enabled("Found enabled driver(s): " + Arrays.toString(annotation.value()));
|
||||
if (!optional.isPresent()) {
|
||||
return ENABLED_BY_DEFAULT;
|
||||
}
|
||||
|
||||
return ENABLED_BY_DEFAULT;
|
||||
EnabledOnRedisDriver annotation = optional.get();
|
||||
Class<?> testClass = context.getRequiredTestClass();
|
||||
|
||||
List<Field> annotatedFields = AnnotationUtils.findAnnotatedFields(testClass,
|
||||
EnabledOnRedisDriver.DriverQualifier.class, it -> RedisConnectionFactory.class.isAssignableFrom(it.getType()));
|
||||
|
||||
if (annotatedFields.isEmpty()) {
|
||||
throw new IllegalStateException(
|
||||
"@WithRedisDriver requires a field of type RedisConnectionFactory annotated with @DriverQualifier!");
|
||||
}
|
||||
|
||||
for (Field field : annotatedFields) {
|
||||
Try<Object> fieldValue = ReflectionUtils.tryToReadFieldValue(field, context.getRequiredTestInstance());
|
||||
|
||||
RedisConnectionFactory value = (RedisConnectionFactory) fieldValue
|
||||
.getOrThrow(e -> new IllegalStateException("Cannot read field " + field, e));
|
||||
|
||||
boolean foundMatch = false;
|
||||
for (RedisDriver redisDriver : annotation.value()) {
|
||||
if (redisDriver.matches(value)) {
|
||||
foundMatch = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMatch) {
|
||||
return disabled(String.format("Driver %s not supported. Supported driver(s): %s", value,
|
||||
Arrays.toString(annotation.value())));
|
||||
}
|
||||
}
|
||||
|
||||
return enabled("Found enabled driver(s): " + Arrays.toString(annotation.value()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -23,13 +23,13 @@ import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.platform.commons.util.AnnotationUtils;
|
||||
|
||||
import org.springframework.data.redis.SettingsUtils;
|
||||
|
||||
/**
|
||||
* {@link ExecutionCondition} for {@link EnabledOnRedisSentinelCondition @EnabledOnRedisSentinelAvailable}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Christoph Strobl
|
||||
* @see EnabledOnRedisSentinelCondition
|
||||
*/
|
||||
class EnabledOnRedisSentinelCondition implements ExecutionCondition {
|
||||
@@ -44,21 +44,20 @@ class EnabledOnRedisSentinelCondition implements ExecutionCondition {
|
||||
Optional<EnabledOnRedisSentinelAvailable> optional = AnnotationUtils.findAnnotation(context.getElement(),
|
||||
EnabledOnRedisSentinelAvailable.class);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
|
||||
EnabledOnRedisSentinelAvailable annotation = optional.get();
|
||||
|
||||
if (RedisDetector.canConnectToPort(annotation.value())) {
|
||||
|
||||
return enabled(String.format("Connection successful to Redis Sentinel at %s:%d", SettingsUtils.getHost(),
|
||||
annotation.value()));
|
||||
}
|
||||
|
||||
return disabled(
|
||||
String.format("Cannot connect to Redis Sentinel at %s:%d", SettingsUtils.getHost(), annotation.value()));
|
||||
if (!optional.isPresent()) {
|
||||
return ENABLED_BY_DEFAULT;
|
||||
}
|
||||
|
||||
return ENABLED_BY_DEFAULT;
|
||||
}
|
||||
EnabledOnRedisSentinelAvailable annotation = optional.get();
|
||||
|
||||
if (RedisDetector.canConnectToPort(annotation.value())) {
|
||||
|
||||
return enabled(String.format("Connection successful to Redis Sentinel at %s:%d", SettingsUtils.getHost(),
|
||||
annotation.value()));
|
||||
}
|
||||
|
||||
return disabled(
|
||||
String.format("Cannot connect to Redis Sentinel at %s:%d", SettingsUtils.getHost(), annotation.value()));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -25,13 +25,12 @@ import org.junit.jupiter.api.extension.ConditionEvaluationResult;
|
||||
import org.junit.jupiter.api.extension.ExecutionCondition;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.junit.platform.commons.util.AnnotationUtils;
|
||||
|
||||
import org.springframework.data.redis.test.extension.LettuceExtension;
|
||||
|
||||
/**
|
||||
* {@link ExecutionCondition} for {@link EnabledOnRedisVersionCondition @EnabledOnVersion}.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
* @author Mark Paluch return ENABLED_BY_DEFAULT;
|
||||
* @see EnabledOnRedisVersionCondition
|
||||
*/
|
||||
class EnabledOnRedisVersionCondition implements ExecutionCondition {
|
||||
@@ -47,26 +46,24 @@ class EnabledOnRedisVersionCondition implements ExecutionCondition {
|
||||
Optional<EnabledOnRedisVersion> optional = AnnotationUtils.findAnnotation(context.getElement(),
|
||||
EnabledOnRedisVersion.class);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
|
||||
String requiredVersion = optional.get().value();
|
||||
|
||||
ExtensionContext.Store store = context.getStore(NAMESPACE);
|
||||
RedisConditions conditions = store.getOrComputeIfAbsent(RedisConditions.class, ignore -> {
|
||||
|
||||
StatefulRedisConnection connection = new LettuceExtension().resolve(context, StatefulRedisConnection.class);
|
||||
return RedisConditions.of(connection);
|
||||
}, RedisConditions.class);
|
||||
|
||||
boolean versionMet = conditions.hasVersionGreaterOrEqualsTo(requiredVersion);
|
||||
return versionMet
|
||||
? enabled(String.format("Enabled on version %s (actual version: %s)", requiredVersion,
|
||||
conditions.getRedisVersion()))
|
||||
: disabled(String.format("Disabled, version %s not available on Redis version %s", requiredVersion,
|
||||
conditions.getRedisVersion()));
|
||||
if (!optional.isPresent()) {
|
||||
return ENABLED_BY_DEFAULT;
|
||||
}
|
||||
|
||||
return ENABLED_BY_DEFAULT;
|
||||
}
|
||||
String requiredVersion = optional.get().value();
|
||||
|
||||
ExtensionContext.Store store = context.getStore(NAMESPACE);
|
||||
RedisConditions conditions = store.getOrComputeIfAbsent(RedisConditions.class, ignore -> {
|
||||
|
||||
StatefulRedisConnection connection = new LettuceExtension().resolve(context, StatefulRedisConnection.class);
|
||||
return RedisConditions.of(connection);
|
||||
}, RedisConditions.class);
|
||||
|
||||
boolean versionMet = conditions.hasVersionGreaterOrEqualsTo(requiredVersion);
|
||||
return versionMet
|
||||
? enabled(
|
||||
String.format("Enabled on version %s (actual version: %s)", requiredVersion, conditions.getRedisVersion()))
|
||||
: disabled(String.format("Disabled, version %s not available on Redis version %s", requiredVersion,
|
||||
conditions.getRedisVersion()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2020 the original author or authors.
|
||||
* Copyright 2020 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -51,6 +51,7 @@ class RedisConditions {
|
||||
String info = commands.info("server");
|
||||
|
||||
try {
|
||||
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(info.getBytes());
|
||||
Properties p = new Properties();
|
||||
p.load(inputStream);
|
||||
|
||||
@@ -28,6 +28,7 @@ public enum ShutdownQueue {
|
||||
INSTANCE;
|
||||
|
||||
static {
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
Reference in New Issue
Block a user