alibaba/Sentinel · error · IllegalArgumentException

Max entry count should be at least 1:

Error message

Max entry count should be at least 1: 

What it means

StatLoggerBuilder.maxEntryCount(int) validates the per-logger entry limit: an EagleEye stat logger caps how many distinct key combinations (entries) it tracks to bound memory. Any value below 1 is rejected with IllegalArgumentException because a logger that can hold zero entries is meaningless.

Source

Thrown at sentinel-core/src/main/java/com/alibaba/csp/sentinel/eagleeye/StatLoggerBuilder.java:47

    private char keyDelimiter = ',';

    private char valueDelimiter = ',';

    private EagleEyeAppender appender = null;

    StatLoggerBuilder(String loggerName) {
        super(loggerName);
    }

    public StatLoggerBuilder intervalSeconds(int intervalSeconds) {
        validateInterval(intervalSeconds);
        this.intervalSeconds = intervalSeconds;
        return this;
    }

    public StatLoggerBuilder maxEntryCount(int maxEntryCount) {
        if (maxEntryCount < 1) {
            throw new IllegalArgumentException("Max entry count should be at least 1: " + maxEntryCount);
        }
        this.maxEntryCount = maxEntryCount;
        return this;
    }

    public StatLoggerBuilder keyDelimiter(char keyDelimiter) {
        this.keyDelimiter = keyDelimiter;
        return this;
    }

    public StatLoggerBuilder valueDelimiter(char valueDelimiter) {
        this.valueDelimiter = valueDelimiter;
        return this;
    }

    StatLoggerBuilder appender(EagleEyeAppender appender) {
        this.appender = appender;
        return this;

View on GitHub (pinned to a3f40ba8e9)

Solutions

  1. Set a positive entry count (e.g. the EagleEye-typical default of 1000 or your measured cardinality) in the builder call.
  2. If the value comes from config, validate it at startup and fall back to a sane default before building the logger.
  3. Add a startup config check so misparsed numbers surface immediately with the config key name.

Example fix

// before
int maxEntries = Integer.getInteger("stat.max.entries", 0);
StatLogger logger = EagleEye.statLoggerBuilder("myStat").maxEntryCount(maxEntries).build();

// after
int maxEntries = Integer.getInteger("stat.max.entries", 1000);
if (maxEntries < 1) { throw new IllegalStateException("stat.max.entries must be >= 1, got " + maxEntries); }
StatLogger logger = EagleEye.statLoggerBuilder("myStat").maxEntryCount(maxEntries).build();
Defensive patterns

Strategy: validation

Validate before calling

int maxEntries = Integer.getInteger("stat.max.entries", 1000);
if (maxEntries < 1) {
    throw new IllegalStateException("stat.max.entries must be >= 1, got " + maxEntries);
}
builder.maxEntryCount(maxEntries);

Prevention

When it happens

Trigger: Calling .maxEntryCount(0) or a negative value on a StatLoggerBuilder — commonly when the limit is read from configuration or a system property that is unset (parsed as 0/-1) or defaulted incorrectly.

Common situations: maxEntryCount wired from a config key that is missing in a new environment. A property placeholder like ${stat.max.entries} that fails to resolve and becomes 0. Arithmetic that derives the count (e.g. base - reserve) going negative under some inputs.

Related errors


AI-assisted analysis of alibaba/Sentinel@a3f40ba8e9 (2026-08-14). Data as JSON: /api/errors/19c86a724fd79c0a. Report an issue: GitHub.