{"record":{"id":"673b95975ff8c017","repo":"redis/jedis","slug":"could-not-destroy-the-pool","errorCode":null,"errorMessage":"Could not destroy the pool","messagePattern":"Could not destroy the pool","errorType":"exception","errorClass":"JedisException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/util/Pool.java","lineNumber":32,"sourceCode":"\n  public Pool(final PooledObjectFactory<T> factory, final GenericObjectPoolConfig<T> poolConfig) {\n    super(factory, poolConfig);\n  }\n\n  public Pool(final PooledObjectFactory<T> factory) {\n    super(factory);\n  }\n\n  @Override\n  public void close() {\n    destroy();\n  }\n\n  public void destroy() {\n    try {\n      super.close();\n    } catch (RuntimeException e) {\n      throw new JedisException(\"Could not destroy the pool\", e);\n    }\n  }\n\n  public T getResource() {\n    try {\n      return super.borrowObject();\n    } catch (JedisException je) {\n      throw je;\n    } catch (Exception e) {\n      throw new JedisException(\"Could not get a resource from the pool\", e);\n    }\n  }\n\n  public void returnResource(final T resource) {\n    if (resource == null) {\n      return;\n    }\n    try {","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/util/Pool.java#L14-L50","documentation":"Pool.destroy() closes the underlying commons-pool2 object pool. If close() throws a RuntimeException, it is wrapped in a JedisException with message \"Could not destroy the pool\". This means the pool's resources could not be released cleanly.","triggerScenarios":"Calling pool.destroy() (directly or via pool.close()) while the internal GenericObjectPool close fails — typically due to a blocked/aborted eviction thread, an exception from a factory destroyObject (e.g. socket close failure), or double-destroy in a broken state.","commonSituations":"Shutting down an application whose Redis connections are in a bad network state; calling destroy() twice concurrently; closing pools while idle-eviction is running.","solutions":["Inspect the wrapped cause (getCause()) to find the underlying pool factory failure.","Ensure connections are returned/closed before destroying the pool.","Guard against double-destroy with an idempotent shutdown hook (close() is already a no-op wrapper-safe path; check your own code for repeated destroy calls).","Check network/firewall state if socket closes time out during destroy."],"exampleFix":"// before\npool.destroy(); // may throw JedisException on flaky sockets\n// after\ntry (Pool<Jedis> p = pool) {\n  // use pool\n} // close() swallows-safe; or:\ntry { pool.destroy(); } catch (JedisException e) {\n  log.warn(\"Pool destroy failed\", e.getCause());\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  pool.destroy();\n} catch (JedisException e) {\n  log.warn(\"Pool destroy failed\", e.getCause());\n}","preventionTips":["Return all resources before destroying the pool.","Make shutdown idempotent (guard double destroy).","Check the cause for socket/network issues during shutdown."],"tags":["pool","shutdown","resource-cleanup"],"backgroundTag":"connection-refused","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"}