{"record":{"id":"98a9f5a8b40271d4","repo":"brettwooldridge/HikariCP","slug":"minimumidle-cannot-be-negative","errorCode":null,"errorMessage":"minimumIdle cannot be negative","messagePattern":"minimumIdle cannot be negative","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/zaxxer/hikari/HikariConfig.java","lineNumber":276,"sourceCode":"      if (maxPoolSize < 1) {\n         throw new IllegalArgumentException(\"maxPoolSize cannot be less than 1\");\n      }\n      this.maxPoolSize = maxPoolSize;\n   }\n\n   /** {@inheritDoc} */\n   @Override\n   public int getMinimumIdle()\n   {\n      return minIdle;\n   }\n\n   /** {@inheritDoc} */\n   @Override\n   public void setMinimumIdle(int minIdle)\n   {\n      if (minIdle < 0) {\n         throw new IllegalArgumentException(\"minimumIdle cannot be negative\");\n      }\n      this.minIdle = minIdle;\n   }\n\n   /**\n    * Get the default password to use for DataSource.getConnection(username, password) calls.\n    * @return the password\n    */\n   public String getPassword()\n   {\n      return credentials.get().getPassword();\n   }\n\n   /**\n    * Set the default password to use for DataSource.getConnection(username, password) calls.\n    * @param password the password\n    */\n   @Override","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/brettwooldridge/HikariCP/blob/a4d93f4f85517f90e632b795486d7102e933d7ff/src/main/java/com/zaxxer/hikari/HikariConfig.java#L258-L294","documentation":"HikariCP throws IllegalArgumentException when setMinimumIdle(int) receives a negative value. minIdle is the number of connections the pool tries to keep warm; a negative count is meaningless. 0 is legal (pool may shrink to zero idle connections), and values above maxPoolSize are not an error — validate() later raises minIdle to maxPoolSize with a warning.","triggerScenarios":"Calling config.setMinimumIdle(n) with n < 0, or a properties/yml entry like minimumIdle=-1. Also triggered when a computed value (e.g. from a sizing formula or env var) underflows to negative.","commonSituations":"Using -1 to signal 'use default' (HikariCP convention: leave minIdle unset or use maxPoolSize for a fixed pool); config templating that substitutes an unset variable as -1; copy-paste from another pool's config dialect.","solutions":["Use a value between 0 and maxPoolSize; 0 lets the pool drain idle connections","For a fixed-size pool, set minIdle equal to maximumPoolSize","Trace the negative value to its source (env var, placeholder) and fix it there"],"exampleFix":"// before\nconfig.setMinimumIdle(-1); // IllegalArgumentException\n\n// after\nconfig.setMinimumIdle(2);\n// fixed-size pool:\nconfig.setMinimumIdle(config.getMaximumPoolSize());","handlingStrategy":"validation","validationCode":"int minIdle = Math.max(0, configuredMinIdle);\nif (minIdle > maxPoolSize) minIdle = maxPoolSize;\nconfig.setMinimumIdle(minIdle);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat -1 as 'use maxPoolSize' in your own config layer and translate before calling HikariCP","Range-check minIdle in [0, maxPoolSize] at config load","Keep pool sizing in one place so min/max stay consistent"],"tags":["hikaricp","configuration","connection-pool","pool-size"],"backgroundTag":null,"analyzedSha":"a4d93f4f85517f90e632b795486d7102e933d7ff","analyzedAt":"2026-08-14T12:11:37.292Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}