diff --git a/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java b/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java index 41bb5b475..14eb75db7 100644 --- a/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java @@ -210,6 +210,8 @@ public class SrpConnection implements RedisConnection { this.queue = queue; } catch (IOException e) { throw new RedisConnectionFailureException("Could not connect", e); + } catch(RedisException e) { + throw new RedisConnectionFailureException("Could not connect", e); } } diff --git a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionFactoryTests.java b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionFactoryTests.java index 38a73313e..9c5837f7f 100644 --- a/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionFactoryTests.java +++ b/src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionFactoryTests.java @@ -17,8 +17,10 @@ package org.springframework.data.redis.connection.srp; import org.junit.Ignore; import org.junit.Test; +import org.springframework.data.redis.RedisConnectionFailureException; import org.springframework.data.redis.SettingsUtils; import org.springframework.data.redis.connection.RedisConnection; +import static org.junit.Assert.fail; /** * Integration test of {@link SrpConnectionFactory} @@ -37,6 +39,18 @@ public class SrpConnectionFactoryTests { connection.ping(); } + @Test + public void testConnectInvalidHost() { + SrpConnectionFactory factory = new SrpConnectionFactory(); + factory.setHostName("fakeHost"); + factory.afterPropertiesSet(); + try { + factory.getConnection(); + fail("Expected a connection failure exception"); + } catch(RedisConnectionFailureException e) { + } + } + @Ignore("Redis must have requirepass set to run this test") @Test public void testConnectWithPassword() {