apache/seatunnel · error · IllegalArgumentException

bytesPerSecond and countPerSecond must be positive

Error message

bytesPerSecond and countPerSecond must be positive

What it means

FlowControlStrategy's constructor requires both rate limits to be strictly positive. It throws IllegalArgumentException when either bytesPerSecond or countPerSecond is zero or negative, because a flow-control strategy with no throughput or no per-second count would stall all traffic.

Solutions

  1. Pass strictly positive values for both bytesPerSecond and countPerSecond
  2. Treat 'unlimited' as disabling flow control upstream rather than passing 0
  3. Validate config values (positive int) before constructing the strategy

Example fix

// before
FlowControlStrategy strategy = new FlowControlStrategy(0, 100);
// after
long bytes = config.getLong("bytes-per-second");
if (bytes <= 0) { bytes = Integer.MAX_VALUE; } // or skip flow control entirely
FlowControlStrategy strategy = new FlowControlStrategy((int) bytes, 100);
Defensive patterns

Strategy: validation

Validate before calling

if (bytesPerSecond <= 0 || countPerSecond <= 0) throw new IllegalArgumentException("flow control rates must be > 0");

Try / catch

try { new FlowControlStrategy(bps, cps); } catch (IllegalArgumentException e) { log.error("Bad flow-control config: {}", e.getMessage()); }

Prevention

When it happens

Trigger: Calling new FlowControlStrategy(x, y) where x <= 0 or y <= 0, e.g. parsing a seatunnel flow-control config with bytes-per-second: 0 or a negative count-per-second.

Common situations: Users set flow-control options to 0 intending 'unlimited', paste negative values from YAML arithmetic, or default placeholders that were never filled in.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/b3feab8930f8049f. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-core/seatunnel-core-starter/src/main/java/org/apache/seatunnel/core/starter/flowcontrol/FlowControlStrategy.java:36

package org.apache.seatunnel.core.starter.flowcontrol;

import org.apache.seatunnel.shade.com.typesafe.config.Config;

import java.util.Map;
import java.util.Optional;

import static org.apache.seatunnel.api.options.EnvCommonOptions.READ_LIMIT_BYTES_PER_SECOND;
import static org.apache.seatunnel.api.options.EnvCommonOptions.READ_LIMIT_ROW_PER_SECOND;

public final class FlowControlStrategy {

    private final int bytesPerSecond;

    private final int countPerSecond;

    FlowControlStrategy(int bytesPerSecond, int countPerSecond) {
        if (bytesPerSecond <= 0 || countPerSecond <= 0) {
            throw new IllegalArgumentException(
                    "bytesPerSecond and countPerSecond must be positive");
        }
        this.bytesPerSecond = bytesPerSecond;
        this.countPerSecond = countPerSecond;
    }

    public int getBytesPerSecond() {
        return bytesPerSecond;
    }

    public int getCountPerSecond() {
        return countPerSecond;
    }

    public static Builder builder() {
        return new Builder();
    }

View on GitHub (pinned to cf67b549a7)