{"record":{"id":"8e2e35f17f869afd","repo":"eclipse-vertx/vert.x","slug":"streamidletimeout-must-be-0","errorCode":null,"errorMessage":"streamIdleTimeout must be >= 0","messagePattern":"streamIdleTimeout must be >= 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/net/EndpointConfig.java","lineNumber":63,"sourceCode":"    this.metricsName = other.metricsName;\n    this.logConfig = other.logConfig != null ? new LogConfig(other.logConfig) : null;\n  }\n\n  /**\n   * @return the endpoint transport config\n   */\n  public abstract TransportConfig getTransportConfig();\n\n  /**\n   * Set the stream idle timeout, zero or {@code null} means don't time out.\n   * This determines if a stream will timeout and be closed if no data is received nor sent within the timeout.\n   *\n   * @param idleTimeout  the idle timeout\n   * @return a reference to this, so the API can be used fluently\n   */\n  public EndpointConfig setIdleTimeout(Duration idleTimeout) {\n    if (idleTimeout != null && idleTimeout.isNegative()) {\n      throw new IllegalArgumentException(\"streamIdleTimeout must be >= 0\");\n    }\n    this.idleTimeout = idleTimeout;\n    return this;\n  }\n\n  /**\n   * @return the idle timeout applied to each stream\n   */\n  public Duration getIdleTimeout() {\n    return idleTimeout;\n  }\n\n  /**\n   * <p>Set the stream read idle timeout, zero or {@code null} means or null means don't time out. This determines if a\n   * stream will timeout and be closed if no data is received within the timeout.</p>\n   *\n   * @param idleTimeout  the read idle timeout\n   * @return a reference to this, so the API can be used fluently","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/net/EndpointConfig.java#L45-L81","documentation":"EndpointConfig.setIdleTimeout(Duration) rejects a negative idle timeout with IllegalArgumentException. Idle timeout defines how long a connection/stream may stay inactive before being closed; a negative value is meaningless, so the setter validates eagerly. Null is allowed (means 'no timeout'), only negative durations throw.","triggerScenarios":"Calling EndpointConfig.setIdleTimeout(Duration.ofSeconds(-1)) or any Duration created from a negative value, e.g. Duration.ofMillis(-500), or a Duration computed from arithmetic that underflowed to negative.","commonSituations":"Reading the timeout from external config (YAML/JSON/env) that holds a negative number; subtracting two durations to compute a timeout and getting a negative result; typos like Duration.parse(\"-PT30S\").","solutions":["Pass a non-negative Duration or null to disable the timeout","Validate the configured value before calling setIdleTimeout","Fix the config source so it does not contain a negative duration"],"exampleFix":"// before\nconfig.setIdleTimeout(Duration.ofSeconds(-30));\n// after\nconfig.setIdleTimeout(Duration.ofSeconds(30)); // or null to disable","handlingStrategy":"validation","validationCode":"if (timeout != null && timeout.isNegative()) { throw new IllegalArgumentException(\"idleTimeout must be >= 0\"); }\nconfig.setIdleTimeout(timeout);","typeGuard":"boolean isValidTimeout(Duration d) { return d == null || !d.isNegative(); }","tryCatchPattern":null,"preventionTips":["Validate Durations read from config files before applying them","Prefer null over negative values to disable timeouts","Avoid Duration arithmetic that can underflow without clamping"],"tags":["validation","illegal-argument","duration","config"],"backgroundTag":"invalid-argument-value","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}