Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
11f700aa
Commit
11f700aa
authored
Jan 30, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix handling of redis password containing a colon
Closes gh-11371
parent
4ecc7b92
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
3 deletions
+25
-3
RedisAutoConfiguration.java
...boot/autoconfigure/data/redis/RedisAutoConfiguration.java
+2
-2
RedisAutoConfigurationTests.java
...autoconfigure/data/redis/RedisAutoConfigurationTests.java
+23
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java
View file @
11f700aa
/*
* Copyright 2012-201
6
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -129,7 +129,7 @@ public class RedisAutoConfiguration {
factory
.
setPort
(
uri
.
getPort
());
if
(
uri
.
getUserInfo
()
!=
null
)
{
String
password
=
uri
.
getUserInfo
();
int
index
=
password
.
lastI
ndexOf
(
":"
);
int
index
=
password
.
i
ndexOf
(
":"
);
if
(
index
>=
0
)
{
password
=
password
.
substring
(
index
+
1
);
}
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationTests.java
View file @
11f700aa
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
...
@@ -91,6 +91,28 @@ public class RedisAutoConfigurationTests {
.
isEqualTo
(
true
);
}
@Test
public
void
testPasswordInUrlWithColon
()
{
load
(
"spring.redis.url:redis://:pass:word@example:33"
);
assertThat
(
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
).
getHostName
())
.
isEqualTo
(
"example"
);
assertThat
(
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
).
getPort
())
.
isEqualTo
(
33
);
assertThat
(
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
).
getPassword
())
.
isEqualTo
(
"pass:word"
);
}
@Test
public
void
testPasswordInUrlStartsWithColon
()
{
load
(
"spring.redis.url:redis://user::pass:word@example:33"
);
assertThat
(
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
).
getHostName
())
.
isEqualTo
(
"example"
);
assertThat
(
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
).
getPort
())
.
isEqualTo
(
33
);
assertThat
(
this
.
context
.
getBean
(
JedisConnectionFactory
.
class
).
getPassword
())
.
isEqualTo
(
":pass:word"
);
}
@Test
public
void
testRedisConfigurationWithPool
()
throws
Exception
{
load
(
"spring.redis.host:foo"
,
"spring.redis.pool.max-idle:1"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment