Skip to content

SpanLimitsBuilder Javadoc states setters must be positive but they accept zero #8515

Description

@thswlsqls

Describe the bug

SpanLimitsBuilder documents five setters as requiring a positive argument, but the code accepts zero. The Javadoc contract does not match the actual behavior.

Steps to reproduce

SpanLimits.builder().setMaxNumberOfAttributes(0); // Javadoc says this throws; it does not

What did you expect to see?

Javadoc that matches the real behavior. The >= 0 check is intentional (PR #7030 relaxed it to follow the spec, which allows 0), so the Javadoc should say the argument must not be negative.

What did you see instead?

setMaxNumberOfAttributes, setMaxNumberOfEvents, setMaxNumberOfLinks, setMaxNumberOfAttributesPerEvent, and setMaxNumberOfAttributesPerLink (SpanLimitsBuilder.java) each say @param ... Must be positive. and @throws IllegalArgumentException if {@code ...} is not positive., but each calls Utils.checkArgument(value >= 0, "... must be non-negative"). Passing 0 is accepted. The sixth setter, setMaxAttributeValueLength, already documents the same >= 0 check correctly as "Must not be negative" / "is negative".

What version and what artifacts are you using?
Artifacts: opentelemetry-sdk-trace
Version: main @ 824334c
How did you reference these artifacts? N/A (source inspection)

Environment
Compiler: Temurin 21
OS: N/A

Additional context

Fix is Javadoc-only, no behavior change. Related: PR #7030.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions