{"record":{"id":"d6a0b4d8c79d9879","repo":"alibaba/Sentinel","slug":"recommendrefreshms-must-0-but-get","errorCode":null,"errorMessage":"recommendRefreshMs must > 0, but {} get","messagePattern":"recommendRefreshMs must > 0, but (.+?) get","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sentinel-extension/sentinel-datasource-extension/src/main/java/com/alibaba/csp/sentinel/datasource/AutoRefreshDataSource.java","lineNumber":45,"sourceCode":" *\n * @param <S> source data type\n * @param <T> target data type\n * @author Carpenter Lee\n */\npublic abstract class AutoRefreshDataSource<S, T> extends AbstractDataSource<S, T> {\n\n    private ScheduledExecutorService service;\n    protected long recommendRefreshMs = 3000;\n\n    public AutoRefreshDataSource(Converter<S, T> configParser) {\n        super(configParser);\n        startTimerService();\n    }\n\n    public AutoRefreshDataSource(Converter<S, T> configParser, final long recommendRefreshMs) {\n        super(configParser);\n        if (recommendRefreshMs <= 0) {\n            throw new IllegalArgumentException(\"recommendRefreshMs must > 0, but \" + recommendRefreshMs + \" get\");\n        }\n        this.recommendRefreshMs = recommendRefreshMs;\n        startTimerService();\n    }\n\n    @SuppressWarnings(\"PMD.ThreadPoolCreationRule\")\n    private void startTimerService() {\n        service = Executors.newScheduledThreadPool(1,\n            new NamedThreadFactory(\"sentinel-datasource-auto-refresh-task\", true));\n        service.scheduleAtFixedRate(new Runnable() {\n            @Override\n            public void run() {\n                try {\n                    if (!isModified()) {\n                        return;\n                    }\n                    T newValue = loadConfig();\n                    getProperty().updateValue(newValue);","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-extension/sentinel-datasource-extension/src/main/java/com/alibaba/csp/sentinel/datasource/AutoRefreshDataSource.java#L27-L63","documentation":"AutoRefreshDataSource schedules periodic readSource()+loadConfig() refreshes every recommendRefreshMs. The constructor validates recommendRefreshMs > 0 because scheduleAtFixedRate with a non-positive period would throw its own IllegalArgumentException immediately inside the timer setup.","triggerScenarios":"new AutoRefreshDataSource(parser, recommendRefreshMs) or any subclass constructor (e.g. new FileRefreshableDataSource(file, parser, 0, bufSize, charset)) with refreshMs <= 0.","commonSituations":"A refresh-interval property set to 0 (sometimes meant as 'disable refresh' — not supported here); unit mix-ups (passing a seconds value of 0/1 where ms expected after a refactor); property placeholders that resolve to 0 when undefined.","solutions":["Set recommendRefreshMs to a positive millisecond value (default in FileRefreshableDataSource is DEFAULT_REFRESH_MS = 3000).","If you intended to disable auto refresh, use a plain (non-refreshing) datasource such as FileInJarReadableDataSource's base or ReadableDataSource directly instead of 0.","Check the property source feeding the interval and give it a sane default when absent."],"exampleFix":"// before\nnew FileRefreshableDataSource<>(file, parser, 0, 1024 * 1024, charset);\n\n// after\nnew FileRefreshableDataSource<>(file, parser, 3000, 1024 * 1024, charset);\n// or omit refresh: new FileRefreshableDataSource<>(file, parser, charset);","handlingStrategy":"validation","validationCode":"long refreshMs = props.getProperty(\"refreshMs\") == null\n    ? 3000L\n    : Long.parseLong(props.getProperty(\"refreshMs\"));\nif (refreshMs <= 0) {\n    throw new ConfigurationException(\"refreshMs must be > 0, got \" + refreshMs);\n}\nnew FileRefreshableDataSource<>(file, parser, refreshMs, bufSize, charset);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat 0 refresh interval as 'use a non-refreshing datasource', not as a constructor argument.","Default refresh properties to 3000ms when absent instead of 0."],"tags":["sentinel","datasource","auto-refresh","validation"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}