@@ -32,6 +32,7 @@ public class JedisResourceProvider implements Provider<Jedis> {
3232 private static final String CONFIGURATION_KEY_CONNECTION_POOL_MAXIMUM_WAIT = "voidframework.redis.connPool.maximumWait" ;
3333 private static final String CONFIGURATION_KEY_HOST = "voidframework.redis.host" ;
3434 private static final String CONFIGURATION_KEY_PORT = "voidframework.redis.port" ;
35+ private static final String CONFIGURATION_KEY_USERNAME = "voidframework.redis.username" ;
3536 private static final String CONFIGURATION_KEY_PASSWORD = "voidframework.redis.password" ;
3637
3738 private final Config configuration ;
@@ -62,6 +63,7 @@ public Jedis get() {
6263 final Duration maximumWait = this .configuration .getDuration (CONFIGURATION_KEY_CONNECTION_POOL_MAXIMUM_WAIT );
6364 final String host = this .configuration .getString (CONFIGURATION_KEY_HOST );
6465 final int port = this .configuration .getInt (CONFIGURATION_KEY_PORT );
66+ final String username = this .configuration .getString (CONFIGURATION_KEY_USERNAME );
6567 final String password = this .configuration .getString (CONFIGURATION_KEY_PASSWORD );
6668
6769 // Checks configuration
@@ -91,7 +93,11 @@ public Jedis get() {
9193 jedisPoolConfig .setMaxWait (maximumWait );
9294
9395 if (StringUtils .isNotBlank (password )) {
94- this .jedisPool = new JedisPool (jedisPoolConfig , host , port , (int ) connectionTimeout , password );
96+ if (StringUtils .isBlank (username )) {
97+ this .jedisPool = new JedisPool (jedisPoolConfig , host , port , (int ) connectionTimeout , password );
98+ } else {
99+ this .jedisPool = new JedisPool (jedisPoolConfig , host , port , (int ) connectionTimeout , username , password );
100+ }
95101 } else {
96102 this .jedisPool = new JedisPool (jedisPoolConfig , host , port , (int ) connectionTimeout );
97103 }
0 commit comments