Skip to content

Report streaming protocol failures as WinRMClientException - #191

Merged
bertysentry merged 2 commits into
mainfrom
188-streaming-terminals-throw-a-raw-illegalstateexception-instead-of-winrmclientexception-for-protocol-failures
Sep 29, 2026
Merged

bertysentry merged 2 commits into
mainfrom
188-streaming-terminals-throw-a-raw-illegalstateexception-instead-of-winrmclientexception-for-protocol-failures

Conversation

@bertysentry

Copy link
Copy Markdown
Contributor

Fixes #188.

The streaming terminals (WqlRequest.stream(), CommandRequest.start(), RemoteFile.openStream()/openReader(), RemoteDirectoryListing.stream()) and RemoteProcess.close() let RuntimeExceptions raised in the WSMan layer escape as-is: an unexpected HTTP status (e.g. a 503 from a proxy), an exhausted authentication fallback or a malformed response surfaced as a raw IllegalStateException instead of the documented WinRMClientException.

Changes

  • LightWinRMService.callStreaming() wraps every non-typed failure in WinRMException, exactly like the blocking path's executeWithTimeout(), so the request classes translate it into WinRMClientException with the raw failure in the cause chain. The typed WinRMClientExceptions (fault, authentication, timeout) still pass through unchanged. One shared helper, so all four terminals and every cursor step are covered.
  • The streaming cursor's close() does the same for a failure answering the terminate Signal.
  • The stdin state checks ("input after the end mark") move out of the protocol step into RemoteCommand.checkStdinOpen(), called before it, so that caller bug stays an IllegalStateException as documented and tested.
  • Three FakeWsmanServer tests: a 503 answering the Enumerate, the shell Create, and the terminate Signal of an early close.
  • CHANGELOG entry.

mvn clean verify site passes: 325 tests, 0 Checkstyle / PMD / SpotBugs findings.

🤖 Generated with Claude Code

Fixes #188. The streaming terminals (WqlRequest.stream(), CommandRequest.start(),
RemoteFile.openStream()/openReader(), RemoteDirectoryListing.stream()) and the
cursor close let RuntimeExceptions raised in the WSMan layer escape as-is, so an
unexpected HTTP status, an exhausted authentication fallback or a malformed
response surfaced as a raw IllegalStateException instead of the documented
WinRMClientException.

LightWinRMService.callStreaming() now wraps every non-typed failure in
WinRMException, exactly like the blocking path's executeWithTimeout(), so the
request classes translate it; the typed WinRMClientExceptions still pass
through. The cursor's close() does the same. The stdin state checks ("input
after the end mark") move out of the protocol step into
RemoteCommand.checkStdinOpen(), called before it, so that caller bug stays an
IllegalStateException.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T18:44:00.337498Z 0ef6344 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 16788af235

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/main/java/org/metricshub/winrm/light/LightWinRMService.java
A handle outliving its client (stream, close the client, advance past the
buffered page) hit WsmanClient's closed guard inside the protocol step, which
callStreaming now wrapped as a protocol failure. The executor's own
checkNotClosed() runs before every streaming step, so the caller bug stays the
documented IllegalStateException.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

} catch (final Exception e) {
throw new WinRMException(e, e.getMessage());

P2 Badge Preserve closed-state errors across the concurrent-close race

When a client shared between threads is closed after callStreaming() passes checkNotClosed() but before WsmanClient.request() checks its volatile closed flag, that request deliberately throws the documented closed-client IllegalStateException; this catch then wraps it in WinRMException, so the fluent API nondeterministically exposes WinRMClientException instead. Fresh evidence beyond the resolved sequential test is this time-of-check/time-of-use window: the client is documented as shareable across threads and WsmanClient explicitly supports close() racing a streaming request, so the closed-state exception needs to remain distinguishable inside this catch as well.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@bertysentry
bertysentry merged commit 0dcf6f4 into main Sep 29, 2026
5 checks passed
@bertysentry
bertysentry deleted the 188-streaming-terminals-throw-a-raw-illegalstateexception-instead-of-winrmclientexception-for-protocol-failures branch September 29, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming terminals throw a raw IllegalStateException instead of WinRMClientException for protocol failures

1 participant