{"record":{"id":"19164d0ac18b045e","repo":"code4craft/webmagic","slug":"emptysleeptime-should-be-more-than-zero","errorCode":null,"errorMessage":"emptySleepTime should be more than zero!","messagePattern":"emptySleepTime should be more than zero!","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"webmagic-core/src/main/java/us/codecraft/webmagic/Spider.java","lineNumber":781,"sourceCode":"    }\n\n    public Date getStartTime() {\n        return startTime;\n    }\n\n    public Scheduler getScheduler() {\n        return scheduler.getScheduler();\n    }\n\n    /**\n     * Set wait time when no url is polled.<br><br>\n     *\n     * @param emptySleepTime In MILLISECONDS.\n     * @return this\n     */\n    public Spider setEmptySleepTime(long emptySleepTime) {\n        if(emptySleepTime<=0){\n            throw new IllegalArgumentException(\"emptySleepTime should be more than zero!\");\n        }\n        this.emptySleepTime = emptySleepTime;\n        return this;\n    }\n}\n","sourceCodeStart":763,"sourceCodeEnd":787,"githubUrl":"https://github.com/code4craft/webmagic/blob/67816a19d68a4fec4657bf1336227e046e251df2/webmagic-core/src/main/java/us/codecraft/webmagic/Spider.java#L763-L787","documentation":"Spider.setEmptySleepTime(long) validates that the wait interval when the scheduler is empty is strictly positive; zero or negative values throw IllegalArgumentException because the thread would spin or wait indefinitely.","triggerScenarios":"Calling spider.setEmptySleepTime(0) or setEmptySleepTime(-100); passing a mis-parsed duration value.","commonSituations":"Treating 0 as 'no sleep' when the API requires a positive value; unit mixups (passing seconds as 0.x fractions truncated to 0).","solutions":["Pass a positive millisecond value, e.g. 1000","If you truly want no wait, choose a small positive value like 1 ms","Validate the configured value before applying it"],"exampleFix":"// before\nspider.setEmptySleepTime(0);\n// after\nspider.setEmptySleepTime(1000);","handlingStrategy":"validation","validationCode":"if (emptySleepTime <= 0) emptySleepTime = 1000; spider.setEmptySleepTime(emptySleepTime);","typeGuard":null,"tryCatchPattern":"try { spider.setEmptySleepTime(t); } catch (IllegalArgumentException e) { spider.setEmptySleepTime(1000L); }","preventionTips":["Remember values are milliseconds and must be positive","Don't use 0 to mean 'no sleep'; pick a small positive value","Validate duration configs centrally"],"tags":["configuration","argument-validation"],"backgroundTag":"invalid-config-value","analyzedSha":"67816a19d68a4fec4657bf1336227e046e251df2","analyzedAt":"2026-09-08T11:15:28.425Z","contentChangedAt":"2026-09-08T11:15:28.425Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}