{"record":{"id":"1e015982a9d06bd4","repo":"eclipse-vertx/vert.x","slug":"streamwriteidletimeout-must-be-0","errorCode":null,"errorMessage":"streamWriteIdleTimeout must be >= 0","messagePattern":"streamWriteIdleTimeout must be >= 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/net/EndpointConfig.java","lineNumber":107,"sourceCode":"  }\n\n  /**\n   * @return the read idle timeout applied to each stream\n   */\n  public Duration getReadIdleTimeout() {\n    return readIdleTimeout;\n  }\n\n  /**\n   * <p>Set the stream write idle timeout, zero or {@code null} means don't time out. This determines if a\n   * stream will timeout and be closed if no data is sent within the timeout.</p>\n   *\n   * @param idleTimeout  the write idle timeout\n   * @return a reference to this, so the API can be used fluently\n   */\n  public EndpointConfig setWriteIdleTimeout(Duration idleTimeout) {\n    if (idleTimeout != null && idleTimeout.isNegative()) {\n      throw new IllegalArgumentException(\"streamWriteIdleTimeout must be >= 0\");\n    }\n    this.writeIdleTimeout = idleTimeout;\n    return this;\n  }\n\n  /**\n   * @return the write idle timeout applied to each stream\n   */\n  public Duration getWriteIdleTimeout() {\n    return writeIdleTimeout;\n  }\n\n\n  /**\n   * @return the metrics name identifying the reported metrics.\n   */\n  public String getMetricsName() {\n    return metricsName;","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/net/EndpointConfig.java#L89-L125","documentation":"EndpointConfig.setWriteIdleTimeout(Duration) throws IllegalArgumentException when given a negative Duration. The write idle timeout bounds how long a stream may send no data before being treated as idle; only null (disabled) or non-negative durations are accepted.","triggerScenarios":"Calling setWriteIdleTimeout(Duration.ofMillis(-1)) or passing a Duration computed to a negative value while configuring an endpoint.","commonSituations":"Config file/env values with negative numbers; arithmetic on Durations that yields a negative result; copy-paste mistakes where a negative offset was reused as a timeout.","solutions":["Pass a non-negative Duration or null","Validate the Duration sign before invoking the setter","Fix the external config that contains the negative value"],"exampleFix":"// before\nDuration t = Duration.between(start, earlierEnd); // negative\nconfig.setWriteIdleTimeout(t);\n// after\nDuration t = Duration.between(earlierEnd, start);\nconfig.setWriteIdleTimeout(t.isNegative() ? null : t);","handlingStrategy":"validation","validationCode":"if (writeIdleTimeout != null && writeIdleTimeout.isNegative()) { throw new IllegalArgumentException(\"writeIdleTimeout must be >= 0\"); }\nconfig.setWriteIdleTimeout(writeIdleTimeout);","typeGuard":"boolean isUsableTimeout(Duration d) { return d == null || d.compareTo(Duration.ZERO) >= 0; }","tryCatchPattern":null,"preventionTips":["Order Duration.between() arguments so the result is non-negative","Sanitize external config values at load time","Use a single config-mapping layer that clamps durations"],"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-14T05:17:10.506Z"}