{"record":{"id":"fbedcd79629c2b1a","repo":"redis/jedis","slug":"jedisconnectionexception","errorCode":null,"errorMessage":"JedisConnectionException","messagePattern":"JedisConnectionException","errorType":"exception","errorClass":"JedisConnectionException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/mcf/TrackingConnectionPool.java","lineNumber":56,"sourceCode":"    }\n\n    @Override\n    public PooledObject<Connection> makeObject() throws Exception {\n      if (failFast) {\n        throw new JedisConnectionException(\"Failed to create connection!\");\n      }\n      try {\n        PooledObject<Connection> object = super.makeObject();\n        // this can make a marginal improvement on fast failover duration!\n        if (failFast) {\n          object.getObject().close();\n          throw new JedisConnectionException(\"Failed to create connection!\");\n        }\n        return object;\n      } catch (JedisConnectionException e) {\n        throw e;\n      } catch (Exception e) {\n        throw new JedisConnectionException(e);\n      }\n    }\n\n    @Override\n    protected void initialize(Connection conn) {\n      // Track the connection while it is being initialized so forceDisconnect() can interrupt\n      // a thread that is blocked inside HELLO/AUTH/CLIENT round-trips.\n      factoryTrackedObjects.add(conn);\n      try {\n        super.initialize(conn);\n      } finally {\n        factoryTrackedObjects.remove(conn);\n      }\n    }\n\n    public void forceDisconnect() {\n      for (Connection connection : factoryTrackedObjects) {\n        try {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/mcf/TrackingConnectionPool.java#L38-L74","documentation":"TrackingConnectionPool.makeObject wraps any non-JedisConnectionException thrown while creating a pooled connection into a new JedisConnectionException whose cause is the original exception. Genuine connection failures (JedisConnectionException) are rethrown unchanged; everything else — DNS resolution errors, factory configuration problems, IO classes, runtime errors — surfaces as this wrapping exception.","triggerScenarios":"Connection factory throws a non-JedisConnectionException during super.makeObject(): unknown host (UnknownHostException wrapped), socket/SSL initialization errors that are not JedisConnectionException, misconfigured ConnectionFactory, or any RuntimeException from the underlying connection setup.","commonSituations":"Wrong hostname/DNS entries for a database endpoint; SSL/TLS misconfiguration on the socket factory; classpath or JDK-level errors inside the connection factory; programming errors in custom ConnectionFactory implementations.","solutions":["Inspect the exception's cause chain (getCause()) to find the root error — the wrapper itself carries no detail.","Fix the underlying cause: correct DNS/host, TLS settings, or ConnectionFactory configuration.","If a custom factory is in use, ensure it either returns a connection or throws JedisConnectionException directly.","Test endpoint reachability (redis-cli PING / nslookup) to separate DNS/network issues from client bugs."],"exampleFix":"// before\n} catch (Exception e) {\n  throw new JedisConnectionException(e); // opaque without cause handling\n}\n// after\ntry {\n  Connection c = pool.getResource();\n} catch (JedisConnectionException e) {\n  Throwable root = e;\n  while (root.getCause() != null) root = root.getCause();\n  log.error(\"connection setup failed: {}\", root.getMessage(), root); // diagnose real cause\n}","handlingStrategy":"try-catch","validationCode":"try { InetAddress.getByName(host); } catch (UnknownHostException e) { /* fix hostname before init */ }","typeGuard":null,"tryCatchPattern":"try {\n  conn = pool.getResource();\n} catch (JedisConnectionException e) {\n  Throwable root = e;\n  while (root.getCause() != null) root = root.getCause();\n  log.error(\"connection setup failed: {}\", root.getMessage(), root);\n}","preventionTips":["Always log the full cause chain, not just the wrapper message.","Validate hostnames and TLS configuration before building the pool.","Keep custom ConnectionFactory implementations throwing JedisConnectionException."],"tags":["connection-pool","wrapped-exception","multi-db"],"backgroundTag":"http-request-failed","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"}