Skip to content

Fix JedisURIHelper.getPassword throwing ArrayIndexOutOfBoundsException for username-only URIs #4003

Closed
@Links2004

Description

@Links2004

Authentication details can be provided in the URI in the form of a username and password.
Redis URIs may contain authentication details that effectively lead to usernames with passwords, password-only, or no authentication.

Examples :

  • Username and Password: redis://username:password@host:port
  • Password-only: redis://:password@host:port
  • No Authentication: redis://host:port
  • Empty password: redis://username:@host:port

Using JedisURIHelper with a URI having only a username is considered invalid and should throw IllegalArgumentException.

  • Username-only: redis://username@host:port

Expected behavior

JedisURIHelper.getPassword throws IllegalArgumentException when there is only a username and no password in the URI.

Actual behavior

JedisURIHelper.getPassword does throw an exception ArrayIndexOutOfBoundsException when there is only a username and no password in the URI.

java.lang.ArrayIndexOutOfBoundsException: Index 1 out of bounds for length 1
	at redis.clients.jedis.util.JedisURIHelper.getPassword(JedisURIHelper.java:36)

Steps to reproduce:

URI redisProperUri = URI.create("redis://[email protected]");
JedisURIHelper.getPassword(redisProperUri); 

Redis / Jedis Configuration

Jedis version:

Redis version:

Java version:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions