{"record":{"id":"1d3be75ce41fb15f","repo":"alibaba/druid","slug":"timebetweenevictionrunsmillis-must-0","errorCode":null,"errorMessage":"timeBetweenEvictionRunsMillis must > 0","messagePattern":"timeBetweenEvictionRunsMillis must > 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java","lineNumber":861,"sourceCode":"    public int getNumTestsPerEvictionRun() {\n        return numTestsPerEvictionRun;\n    }\n\n    /**\n     * @param numTestsPerEvictionRun number of tests per eviction run\n     */\n    @Deprecated\n    public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun) {\n        this.numTestsPerEvictionRun = numTestsPerEvictionRun;\n    }\n\n    public long getTimeBetweenEvictionRunsMillis() {\n        return timeBetweenEvictionRunsMillis;\n    }\n\n    public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis) {\n        if (timeBetweenEvictionRunsMillis <= 0) {\n            throw new IllegalArgumentException(\"timeBetweenEvictionRunsMillis must > 0\");\n        }\n\n        this.timeBetweenEvictionRunsMillis = timeBetweenEvictionRunsMillis;\n    }\n\n    public int getMaxWaitThreadCount() {\n        return maxWaitThreadCount;\n    }\n\n    public void setMaxWaitThreadCount(int maxWaithThreadCount) {\n        this.maxWaitThreadCount = maxWaithThreadCount;\n    }\n\n    public String getValidationQuery() {\n        return validationQuery;\n    }\n\n    public void setValidationQuery(String validationQuery) {","sourceCodeStart":843,"sourceCodeEnd":879,"githubUrl":"https://github.com/alibaba/druid/blob/fa8dc9912637a2f729eef9f55356621fec18d40e/core/src/main/java/com/alibaba/druid/pool/DruidAbstractDataSource.java#L843-L879","documentation":"setTimeBetweenEvictionRunsMillis rejects any value <= 0, regardless of init state. This interval drives the evictor thread (a negative/zero period cannot schedule the Timer/ScheduledExecutor). There is no advisory path - the exception is unconditional.","triggerScenarios":"Calling setTimeBetweenEvictionRunsMillis(0) or with a negative value, e.g. from a property source that resolves to 0 when unset.","commonSituations":"A placeholder (${timeBetweenEvictionRunsMillis}) that resolves to empty/0 because the property was not defined; Spring @Value defaulting to 0; disabling eviction by setting 0 (not supported - to disable, omit the call).","solutions":["Provide a positive value (typical: 60000ms; must be > 0).","If you intended to disable the evictor, simply do not call the setter / leave the property unset rather than passing 0.","Fix unresolved property placeholders so they do not coerce to 0."],"exampleFix":"// before\n// ds.setTimeBetweenEvictionRunsMillis(0); // throws\n\n// after\n// ds.setTimeBetweenEvictionRunsMillis(60000);","handlingStrategy":"validation","validationCode":"long v = configuredInterval;\nif (v <= 0) throw new IllegalArgumentException(\"timeBetweenEvictionRunsMillis must > 0\");\nds.setTimeBetweenEvictionRunsMillis(v);","typeGuard":null,"tryCatchPattern":"try {\n    ds.setTimeBetweenEvictionRunsMillis(value);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"timeBetweenEvictionRunsMillis must > 0\")) {\n        // supply a positive value; to disable eviction, omit the call entirely\n    }\n    throw e;\n}","preventionTips":["Always provide a positive eviction interval (typical 60000ms).","Fix unresolved placeholder/property values so they do not coerce to 0.","To disable the evictor, do not call the setter rather than passing 0."],"tags":["datasource","eviction","validation","configuration"],"backgroundTag":null,"analyzedSha":"fa8dc9912637a2f729eef9f55356621fec18d40e","analyzedAt":"2026-08-14T04:55:06.789Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}