Fix regression of PublishOptions getStreamTimeout - #1611
Conversation
|
Claude finished @scottf's task in 2m 22s —— View job PR Review
SummaryThe fix correctly identifies the problem and adds the right call site, but there is a subtle bug in the null-check logic that means Issue Found: Dead null-check / silent timeout changeFile: Duration timeout = options == null || options.getStreamTimeout() == null ? getTimeout() : options.getStreamTimeout();The intent is clear — fall back to the context's // PublishOptions.Builder
Duration streamTimeout = DEFAULT_TIMEOUT; // never null
// and the setter converts null → DEFAULT_TIMEOUT too
this.streamTimeout = validateDurationNotRequiredGtOrEqZero(timeout, DEFAULT_TIMEOUT);Because there is no public way to construct a Practical effect: whenever Suggested fix — initialise the builder field to // PublishOptions.Builder
Duration streamTimeout = null; // null = "not set"
public Builder streamTimeout(Duration timeout) {
// keep existing validation; null stays null → "not set"
this.streamTimeout = timeout == null ? null : validateDurationNotRequiredGtOrEqZero(timeout, null);
return this;
}Then Everything else looks correct
|
| } | ||
|
|
||
| Message resp = makeInternalRequestResponseRequired(subject, merged, data, getTimeout(), CancelAction.COMPLETE, conn.forceFlushOnRequest); | ||
| Duration timeout = options == null || options.getStreamTimeout() == null ? getTimeout() : options.getStreamTimeout(); |
There was a problem hiding this comment.
options.getStreamTimeout() == null is dead code: PublishOptions.Builder initialises streamTimeout to DEFAULT_TIMEOUT and the setter also converts null → DEFAULT_TIMEOUT, so the field can never be null. Whenever options != null, this line will always use options.getStreamTimeout() (= 2 s default), ignoring the context's requestTimeout for callers who passed PublishOptions without setting streamTimeout.
To make "user did not set a timeout" distinguishable, initialise Builder.streamTimeout = null and let the null-guard here fall through to getTimeout() when it is unset.
Fixed regression reported in #1610