Advanced Request Behavior Option#1582
Conversation
|
@claude review |
|
Claude finished @scottf's task in 5m 19s —— View job Code Review: Advanced Request Behavior OptionTasks
The feature is well-conceived and the opt-in design is correct — off by default, backward-compatible, and the JetStream/core split (throw vs. return) is a reasonable design choice that keeps existing That said, I found several issues ranging from a real bug to API design concerns. Bug:
|
|
@claude review again |
|
Claude finished @scottf's task in 2m 55s —— View job Code Review (Re-review)Tasks
All seven issues from the previous review have been addressed. The implementation is in good shape. I found only minor remaining concerns. Previous issues — all resolved
The rename from Remaining minor concerns1. catch (ExecutionException e) {
cause = e.getCause(); // getCause() can theoretically return null
}The 2. public RequestFailureMessage(NatsRequestCompletableFuture future, ...)
3. Wildcard import in The change replaced four explicit imports with 4. PR description code example is now stale The PR body still shows Positive notes
|
|
@claude one last review. Here are comments on your last items
|
|
Claude finished @scottf's task in 52s —— View job Final ReviewTasks
All four responses are accepted. Here is my assessment of each: 1. Correct. 2. Correct. The class is 3. Wildcard import in Accepted. Wildcard imports are a style choice. The previous explicit imports were fine, so is the wildcard — this is the project's call to make. 4. Stale PR description code example — FIXED ✅ Confirmed. SummaryAll issues from the two prior reviews are resolved. The implementation is correct, the API surface is clean, and the opt-in design is backward-compatible. This PR is ready to merge. |
Address #1581
This adds an opt-in connection option,
advancedRequestBehavior, that surfaces why a request came back without a response instead of the generic timeout. The detail is a classifiedRequestFailureReason— one ofTIMEOUT,CONNECTION_CLOSING,NO_RESPONDERS,PROTOCOL_ERROR, orCANCELLED— plus the connection status, the last protocol error, how long the request waited, and the original exception chained as the cause, so you can tell a real timeout apart from a reconnect, a permissions error, or no stream on the subject.It applies to both request styles:
RequestFailureExceptionin place of the genericIOException("Timeout or no response waiting for NATS JetStream server").Connection.request(...)returns aRequestFailureMessage(which is aMessage) instead ofnull, which you can inspect for the same detail.The option is off by default; existing behavior is unchanged unless you enable in the connection options.
For a core request, the message will never be null. It will either be the response message or will be a RequestFailureMessage. You must inspect the returned message:
The two paths are distinct: a JetStream request throws
RequestFailureException(which extendsIOException, so existingcatch (IOException)blocks keep working), while a corerequest(...)returns theRequestFailureMessage— it does not throw.