{"record":{"id":"16055ae7b4286be2","repo":"redis/jedis","slug":"must-not-instantiate-this-class-16055a","errorCode":null,"errorMessage":"Must not instantiate this class","messagePattern":"Must not instantiate this class","errorType":"exception","errorClass":"InstantiationError","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/util/JedisURIHelper.java","lineNumber":40,"sourceCode":" * <h2>Authentication</h2>\n * <p>Authentication details can be provided in the URI in the form of a username and password.\n * Redis URIs may contain authentication details that effectively lead to usernames with passwords,\n * password-only, or no authentication.</p>\n * <h3>Examples:</h3>\n * <ul>\n *   <li><b>Username and Password:</b> redis://username:password@host:port</li>\n *   <li><b>Password-only:</b> redis://:password@host:port</li>\n *   <li><b>Empty password:</b> redis://username:@host:port</li>\n *   <li><b>No Authentication:</b> redis://host:port</li>\n * </ul>\n */\npublic final class JedisURIHelper {\n\n  private static final String REDIS = \"redis\";\n  private static final String REDISS = \"rediss\";\n\n  private JedisURIHelper() {\n    throw new InstantiationError(\"Must not instantiate this class\");\n  }\n\n  public static HostAndPort getHostAndPort(URI uri) {\n    return new HostAndPort(uri.getHost(), uri.getPort());\n  }\n\n  /**\n   * Extracts the user from the given URI.\n   * <p>\n   * For details on the URI format and authentication examples, see {@link JedisURIHelper}.\n   * </p>\n   * @param uri the URI to extract the user from\n   * @return the user as a String, or null if user is empty or {@link URI#getUserInfo()} info is missing\n   */\n  public static String getUser(URI uri) {\n    String userInfo = uri.getUserInfo();\n    if (userInfo != null) {\n      String user = userInfo.split(\":\", 2)[0];","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/util/JedisURIHelper.java#L22-L58","documentation":"JedisURIHelper is a final utility class with only static helpers (URI parsing for redis/rediss URIs). Its private constructor deliberately throws InstantiationError to signal that instantiation is a programming mistake. The library forbids instances so callers must use the static methods directly.","triggerScenarios":"Calling `new JedisURIHelper()` — the only way to trigger it, since all public members are static and the class is final.","commonSituations":"Developers used to non-static utility APIs instantiate the class before calling getHostAndPort/getPassword/getRedisProtocol; IDE auto-complete or refactoring tools may generate an instance unnecessarily.","solutions":["Remove the instantiation and call the static methods directly, e.g. JedisURIHelper.getHostAndPort(uri).","If you wrapped the class, make your wrapper's methods static too.","Check import/IDE quick-fixes that inserted `new JedisURIHelper()` and delete it."],"exampleFix":"// before\nJedisURIHelper helper = new JedisURIHelper();\nHostAndPort hp = helper.getHostAndPort(uri);\n// after\nHostAndPort hp = JedisURIHelper.getHostAndPort(uri);","handlingStrategy":"validation","validationCode":"// Never instantiate; assert you only reference static methods.\nHostAndPort hp = JedisURIHelper.getHostAndPort(uri);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat utility classes as static-only APIs.","Enable IDE inspections that flag needless instantiation of private-constructor classes."],"tags":["instantiation","utility-class","api-usage"],"backgroundTag":"unsupported-operation","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}