Skip to content

Commit

Permalink
Guard RedisURI creation against URI without scheme #694
Browse files Browse the repository at this point in the history
  • Loading branch information
mp911de committed Feb 16, 2018
1 parent e77a26f commit 07ed1b8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/com/lambdaworks/redis/RedisURI.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,10 @@ public URI toURI() {
}

private static RedisURI buildRedisUriFromUri(URI uri) {

LettuceAssert.notNull(uri, "URI must not be null");
LettuceAssert.notNull(uri.getScheme(), "URI scheme must not be null");

Builder builder;
if (uri.getScheme().equals(URI_SCHEME_REDIS_SENTINEL)) {
builder = configureSentinel(uri);
Expand Down
5 changes: 5 additions & 0 deletions src/test/java/com/lambdaworks/redis/RedisURITest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public void simpleUriTest() {
assertThat(redisURI.toURI().toString()).isEqualTo("redis://localhost");
}

@Test(expected = IllegalArgumentException.class)
public void shouldThrowIllegalArgumentExceptionOnMalformedUri() {
RedisURI.create("localhost");
}

@Test
public void sslUriTest() {
RedisURI redisURI = RedisURI.create("redis+ssl://localhost:6379");
Expand Down

0 comments on commit 07ed1b8

Please sign in to comment.