Skip to content

Commit e94fa9a

Browse files
committed
Throw translated Exception on SRP conn failure
DATAREDIS-234
1 parent 6290cba commit e94fa9a

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/main/java/org/springframework/data/redis/connection/srp/SrpConnection.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ public SrpConnection(String host, int port, BlockingQueue<SrpConnection> queue)
210210
this.queue = queue;
211211
} catch (IOException e) {
212212
throw new RedisConnectionFailureException("Could not connect", e);
213+
} catch(RedisException e) {
214+
throw new RedisConnectionFailureException("Could not connect", e);
213215
}
214216
}
215217

src/test/java/org/springframework/data/redis/connection/srp/SrpConnectionFactoryTests.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@
1717

1818
import org.junit.Ignore;
1919
import org.junit.Test;
20+
import org.springframework.data.redis.RedisConnectionFailureException;
2021
import org.springframework.data.redis.SettingsUtils;
2122
import org.springframework.data.redis.connection.RedisConnection;
23+
import static org.junit.Assert.fail;
2224

2325
/**
2426
* Integration test of {@link SrpConnectionFactory}
@@ -37,6 +39,18 @@ public void testConnect() {
3739
connection.ping();
3840
}
3941

42+
@Test
43+
public void testConnectInvalidHost() {
44+
SrpConnectionFactory factory = new SrpConnectionFactory();
45+
factory.setHostName("fakeHost");
46+
factory.afterPropertiesSet();
47+
try {
48+
factory.getConnection();
49+
fail("Expected a connection failure exception");
50+
} catch(RedisConnectionFailureException e) {
51+
}
52+
}
53+
4054
@Ignore("Redis must have requirepass set to run this test")
4155
@Test
4256
public void testConnectWithPassword() {

0 commit comments

Comments
 (0)