{"record":{"id":"18dfa772f581d36a","repo":"eclipse-vertx/vert.x","slug":"streamreadidletimeout-must-be-0","errorCode":null,"errorMessage":"streamReadIdleTimeout must be >= 0","messagePattern":"streamReadIdleTimeout must be >= 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/net/EndpointConfig.java","lineNumber":85,"sourceCode":"  }\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\n   */\n  public EndpointConfig setReadIdleTimeout(Duration idleTimeout) {\n    if (idleTimeout != null && idleTimeout.isNegative()) {\n      throw new IllegalArgumentException(\"streamReadIdleTimeout must be >= 0\");\n    }\n    this.readIdleTimeout = idleTimeout;\n    return this;\n  }\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","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/net/EndpointConfig.java#L67-L103","documentation":"EndpointConfig.setReadIdleTimeout(Duration) throws IllegalArgumentException when given a negative Duration. The read idle timeout bounds how long a stream may receive no data before it is considered idle; negative values are invalid. Null disables the timeout.","triggerScenarios":"Calling setReadIdleTimeout with a negative Duration such as Duration.ofSeconds(-5) or a negatively computed Duration passed to a client/server endpoint configuration.","commonSituations":"Negative timeout values read from configuration files or environment variables; misuse of Duration.between() where the arguments are reversed.","solutions":["Pass a non-negative Duration or null","Add a guard like d == null || !d.isNegative() before calling the setter","Correct the config source supplying the negative value"],"exampleFix":"// before\nconfig.setReadIdleTimeout(Duration.parse(\"-PT10S\"));\n// after\nconfig.setReadIdleTimeout(Duration.ofSeconds(10));","handlingStrategy":"validation","validationCode":"if (readIdleTimeout != null && readIdleTimeout.isNegative()) { throw new IllegalArgumentException(\"readIdleTimeout must be >= 0\"); }\nconfig.setReadIdleTimeout(readIdleTimeout);","typeGuard":"boolean isNonNegativeOrNull(Duration d) { return d == null || !d.isNegative(); }","tryCatchPattern":null,"preventionTips":["Centralize Duration sanitization in a helper used by all config code","Check config-derived numbers for negative signs early","Remember null means 'no timeout' for Vert.x idle settings"],"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"}