{"record":{"id":"7d78020dbcea59a4","repo":"redis/jedis","slug":"endpoint-endpoint-does-not-exist-in-the-provide","errorCode":null,"errorMessage":"Endpoint ${endpoint} does not exist in the provider","messagePattern":"Endpoint (.+?) does not exist in the provider","errorType":"validation","errorClass":"JedisValidationException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java","lineNumber":266,"sourceCode":"      addDatabaseInternal(multiDbConfig, databaseConfig);\n    } finally {\n      activeDatabaseChangeLock.unlock();\n    }\n  }\n\n  /**\n   * Removes a database endpoint from the provider.\n   * @param endpoint the endpoint to remove\n   * @throws JedisValidationException if the endpoint doesn't exist or is the last remaining\n   *           endpoint\n   */\n  public void remove(Endpoint endpoint) {\n    if (endpoint == null) {\n      throw new JedisValidationException(\"Endpoint must not be null\");\n    }\n\n    if (!databaseMap.containsKey(endpoint)) {\n      throw new JedisValidationException(\n          \"Endpoint \" + endpoint + \" does not exist in the provider\");\n    }\n\n    if (databaseMap.size() < 2) {\n      throw new JedisValidationException(\"Cannot remove the last remaining endpoint\");\n    }\n    log.debug(\"Removing endpoint {}\", endpoint);\n\n    Map.Entry<Endpoint, Database> notificationData = null;\n    activeDatabaseChangeLock.lock();\n    try {\n      Database databaseToRemove = databaseMap.get(endpoint);\n      boolean isActiveDatabase = (activeDatabase == databaseToRemove);\n\n      if (isActiveDatabase) {\n        log.info(\"Active database is being removed. Finding a new active database...\");\n        Map.Entry<Endpoint, Database> candidate = findWeightedHealthyDatabaseToIterate(\n          databaseToRemove);","sourceCodeStart":248,"sourceCodeEnd":284,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/mcf/MultiDbConnectionProvider.java#L248-L284","documentation":"remove(Endpoint) throws a JedisValidationException when the given endpoint is not present in the provider's databaseMap. You can only remove databases that were previously registered via the constructor config or add().","triggerScenarios":"Calling provider.remove(endpoint) with an endpoint that was never added, was already removed, or differs from the registered one (e.g. different port or hostname spelling).","commonSituations":"Double removal during shutdown; removing endpoints by string comparison where Endpoint instances don't match registered ones; stale references after a provider rebuild.","solutions":["Verify the endpoint is registered before removing (keep your own set of added endpoints, or check the provider's state).","Make removal idempotent: catch JedisValidationException and skip 'does not exist' cases.","Confirm the Endpoint host/port exactly matches what was configured or added."],"exampleFix":"// before\nprovider.remove(endpoint); // throws if not present\n\n// after\ntry {\n  provider.remove(endpoint);\n} catch (JedisValidationException e) {\n  // endpoint not registered; ignore\n}","handlingStrategy":"validation","validationCode":"// only remove endpoints you know you added\nif (addedEndpoints.remove(endpoint)) {\n  provider.remove(endpoint);\n}","typeGuard":null,"tryCatchPattern":"try {\n  provider.remove(endpoint);\n} catch (JedisValidationException e) {\n  if (e.getMessage().contains(\"does not exist\")) {\n    // already removed; treat as idempotent\n  } else {\n    throw e;\n  }\n}","preventionTips":["Mirror provider state in your own endpoint registry.","Make removal logic idempotent for shutdown/retry paths.","Ensure Endpoint host/port match exactly what was registered."],"tags":["validation","entity-not-found","multi-db"],"backgroundTag":"resource-not-found","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"}