{"record":{"id":"7f0f8d17ff398a7b","repo":"apache/beam","slug":"timerfrequency-must-be-greater-than-zero","errorCode":null,"errorMessage":"timerFrequency must be greater than zero","messagePattern":"timerFrequency must be greater than zero","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/AsyncWrapper.java","lineNumber":197,"sourceCode":"        idFn,\n        useThreadPool,\n        null);\n  }\n\n  public AsyncWrapper(\n      DoFn<InputT, OutputT> syncFn,\n      int parallelism,\n      Duration timerFrequency,\n      @Nullable Integer maxItemsToBuffer,\n      @Nullable Duration timeout,\n      @Nullable Duration maxWaitTime,\n      @Nullable SerializableFunction<InputT, Object> idFn,\n      boolean useThreadPool,\n      @Nullable Coder<KV<K, InputT>> coder) {\n    this.syncFn = syncFn;\n    this.parallelism = parallelism;\n    if (timerFrequency.getMillis() <= 0) {\n      throw new IllegalArgumentException(\"timerFrequency must be greater than zero\");\n    }\n    this.timerFrequency = timerFrequency;\n    this.maxItemsToBuffer =\n        (maxItemsToBuffer != null)\n            ? maxItemsToBuffer\n            : Math.max(parallelism * 2, DEFAULT_MIN_BUFFER_CAPACITY);\n    this.timeout = (timeout != null) ? timeout : Duration.standardSeconds(DEFAULT_TIMEOUT_SEC);\n    this.maxWaitTime =\n        (maxWaitTime != null) ? maxWaitTime : Duration.millis(DEFAULT_MAX_WAIT_TIME_MS);\n    this.idFn =\n        (idFn != null)\n            ? idFn\n            : (SerializableFunction<InputT, Object>)\n                input -> java.util.Objects.requireNonNull(input);\n    this.useThreadPool = useThreadPool;\n    this.uuid = UUID.randomUUID().toString();\n    this.toProcessSpec = (coder != null) ? StateSpecs.bag(coder) : StateSpecs.bag();\n  }","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/AsyncWrapper.java#L179-L215","documentation":"AsyncWrapper schedules a timer-driven maintenance tick using a user-supplied timerFrequency Duration. If the duration's milliseconds are zero or negative the timer loop would spin or never fire correctly, so the constructor throws IllegalArgumentException. This validates configuration at pipeline construction time rather than failing at runtime.","triggerScenarios":"Building an AsyncWrapper (via its builder/constructor) with Duration.ZERO, Duration.millis(0), or a negative Duration for timerFrequency.","commonSituations":"Developers pass Duration.ZERO assuming 'as fast as possible', or compute the duration from config where a 0 default slipped through.","solutions":["Pass a positive Duration, e.g. Duration.millis(100) or larger","Guard config-driven values: if (millis <= 0) millis = defaultTimerFrequencyMillis","If you want a pure callback-driven design, check whether the wrapper supports disabling timers instead of using 0"],"exampleFix":"// before\nAsyncWrapper.wrap(fn, parallelism).withTimerFrequency(Duration.ZERO);\n// after\nAsyncWrapper.wrap(fn, parallelism).withTimerFrequency(Duration.millis(100));","handlingStrategy":"validation","validationCode":"if (timerFrequency == null || timerFrequency.getMillis() <= 0) {\n  timerFrequency = Duration.millis(100);\n}","typeGuard":null,"tryCatchPattern":"try {\n  builder.withTimerFrequency(freq);\n} catch (IllegalArgumentException e) {\n  builder.withTimerFrequency(Duration.millis(100));\n}","preventionTips":["Never pass Duration.ZERO or negative durations as frequencies","Validate config files that supply timer values before building the pipeline","Pick frequencies well above scheduler granularity (>= 10ms)"],"tags":["java","apache-beam","illegal-argument","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}