{"record":{"id":"9714767740e887c7","repo":"quarkusio/quarkus","slug":"delay-must-be-0-delay","errorCode":null,"errorMessage":"Delay must be > 0: <delay>","messagePattern":"Delay must be > 0: <delay>","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/SseEventSourceBuilderImpl.java","lineNumber":27,"sourceCode":"\npublic class SseEventSourceBuilderImpl extends SseEventSource.Builder {\n\n    private WebTarget endpoint;\n    // defaults set by spec\n    private TimeUnit reconnectUnit = TimeUnit.MILLISECONDS;\n    private long reconnectDelay = 500;\n\n    @Override\n    protected Builder target(WebTarget endpoint) {\n        this.endpoint = endpoint;\n        return this;\n    }\n\n    @Override\n    public Builder reconnectingEvery(long delay, TimeUnit unit) {\n        Objects.requireNonNull(unit);\n        if (delay <= 0)\n            throw new IllegalArgumentException(\"Delay must be > 0: \" + delay);\n        this.reconnectDelay = delay;\n        this.reconnectUnit = unit;\n        return this;\n    }\n\n    @Override\n    public SseEventSource build() {\n        return new SseEventSourceImpl((WebTargetImpl) endpoint, endpoint.request(), reconnectDelay, reconnectUnit);\n    }\n\n}\n","sourceCodeStart":9,"sourceCodeEnd":39,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/resteasy-reactive/client/runtime/src/main/java/org/jboss/resteasy/reactive/client/impl/SseEventSourceBuilderImpl.java#L9-L39","documentation":"SseEventSourceBuilderImpl.reconnectingEvery validates the SSE reconnect delay before storing it and throws this IllegalArgumentException if the delay is not strictly positive. The delay controls how long the client waits before reconnecting after an SSE stream drops.","triggerScenarios":"Calling builder.reconnectingEvery(0, TimeUnit.SECONDS) or a negative delay on a WebTarget's SseEventSource.Builder; passing a computed/variable delay that ended up <= 0 (e.g. Math.round of a small fraction).","commonSituations":"Config value parsed from properties defaulting to 0 when unset; computing delay from milliseconds division that truncates to 0; passing delay in the wrong unit (ms value used as seconds then converted to 0).","solutions":["Pass a strictly positive delay, e.g. reconnectingEvery(1, TimeUnit.SECONDS)","Clamp the configured value: if (delay <= 0) delay = DEFAULT_RECONNECT_DELAY;","Fix the unit conversion so the numeric value is positive before the call"],"exampleFix":"// before\nlong delay = TimeUnit.MILLISECONDS.toSeconds(500); // 0\nbuilder.reconnectingEvery(delay, TimeUnit.SECONDS);\n// after\nbuilder.reconnectingEvery(500, TimeUnit.MILLISECONDS);","handlingStrategy":"validation","validationCode":"if (unit == null) throw new IllegalArgumentException(\"unit required\");\nlong millis = unit.toMillis(delay);\nif (delay <= 0 || millis <= 0) {\n    delay = 1; millis = 1; // clamp to minimum\n}\nbuilder.reconnectingEvery(delay, unit);","typeGuard":"boolean isValidReconnectDelay(long delay, TimeUnit unit) {\n    return unit != null && delay > 0;\n}","tryCatchPattern":"try {\n    builder.reconnectingEvery(delay, unit);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().startsWith(\"Delay must be > 0\")) {\n        builder.reconnectingEvery(1, TimeUnit.SECONDS); // safe default\n    } else throw e;\n}","preventionTips":["Clamp configured reconnect delays to a minimum of 1","Beware truncation when converting small durations between TimeUnits","Validate duration config values at startup"],"tags":["sse","rest-client-reactive","illegal-argument","validation"],"backgroundTag":"invalid-delay-parameter","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}