diff --git a/src/test/java/org/springframework/data/redis/test/extension/JedisExtension.java b/src/test/java/org/springframework/data/redis/test/extension/JedisExtension.java index d438926b3d..e5440dfdb6 100644 --- a/src/test/java/org/springframework/data/redis/test/extension/JedisExtension.java +++ b/src/test/java/org/springframework/data/redis/test/extension/JedisExtension.java @@ -45,7 +45,7 @@ * callbacks. The following resource types are supported by this extension: * * *
@@ -66,6 +66,7 @@
  * is managed by this extension.
  *
  * @author Mark Paluch
+ * @author John Blum
  * @see ParameterResolver
  * @see BeforeEachCallback
  */
@@ -86,18 +87,14 @@ public boolean supportsParameter(ParameterContext parameterContext, ExtensionCon
 	}
 
 	/**
-	 * Attempt to resolve the {@code requestedResourceType}.
-	 *
-	 * @param extensionContext
-	 * @param requestedResourceType
-	 * @param 
-	 * @return
+	 * Attempt to resolve the {@link Class requestedResourceType}.
 	 */
+	@SuppressWarnings("unchecked")
 	public  T resolve(ExtensionContext extensionContext, Class requestedResourceType) {
 
 		ExtensionContext.Store store = getStore(extensionContext);
 
-		return (T) store.getOrComputeIfAbsent(requestedResourceType, it -> findSupplier(requestedResourceType).get());
+		return (T) store.getOrComputeIfAbsent(requestedResourceType, it -> doGetInstance(requestedResourceType));
 	}
 
 	@Override
@@ -111,6 +108,10 @@ public Object resolveParameter(ParameterContext parameterContext, ExtensionConte
 		return store.getOrComputeIfAbsent(parameter.getType(), it -> doGetInstance(parameterizedType));
 	}
 
+	private Object doGetInstance(Type parameterizedType) {
+		return findSupplier(parameterizedType).get();
+	}
+
 	@SuppressWarnings("unchecked")
 	private static Supplier findSupplier(Type type) {
 
@@ -120,30 +121,26 @@ private static Supplier findSupplier(Type type) {
 
 			ResolvableType providedType = ResolvableType.forType(it.getClass()).as(Supplier.class).getGeneric(0);
 
-			if (requested.isAssignableFrom(providedType)) {
-				return true;
-			}
-			return false;
+			return requested.isAssignableFrom(providedType);
+
 		}).findFirst().orElseThrow(() -> new NoSuchElementException("Cannot find a factory for " + type));
 
 		return (Supplier) supplier;
 	}
 
-	private Object doGetInstance(Type parameterizedType) {
-		return findSupplier(parameterizedType).get();
-	}
-
 	private ExtensionContext.Store getStore(ExtensionContext extensionContext) {
 		return extensionContext.getStore(NAMESPACE);
 	}
 
 	static class ResourceFunction {
 
+		final Function function;
+
 		final ResolvableType dependsOn;
 		final ResolvableType provides;
-		final Function function;
 
 		public ResourceFunction(ResolvableType dependsOn, ResolvableType provides, Function function) {
+
 			this.dependsOn = dependsOn;
 			this.provides = provides;
 			this.function = (Function) function;
@@ -155,9 +152,11 @@ enum JedisSupplier implements Supplier {
 		INSTANCE;
 
 		final Lazy lazy = Lazy.of(() -> {
+
 			Jedis client = new Jedis(SettingsUtils.getHost(), SettingsUtils.getPort());
 
-			ShutdownQueue.INSTANCE.register(client);
+			ShutdownQueue.register(client);
+
 			return client;
 		});
 
@@ -172,9 +171,13 @@ enum JedisClusterSupplier implements Supplier {
 		INSTANCE;
 
 		final Lazy lazy = Lazy.of(() -> {
-			JedisCluster client = new JedisCluster(new HostAndPort(SettingsUtils.getHost(), SettingsUtils.getClusterPort()));
 
-			ShutdownQueue.INSTANCE.register(client);
+			HostAndPort hostAndPort = new HostAndPort(SettingsUtils.getHost(), SettingsUtils.getClusterPort());
+
+			JedisCluster client = new JedisCluster(hostAndPort);
+
+			ShutdownQueue.register(client);
+
 			return client;
 		});
 
@@ -183,5 +186,4 @@ public JedisCluster get() {
 			return lazy.get();
 		}
 	}
-
 }