Close SSH channel gracefully on exceptions in port forwarding#885
Merged
tomaswolf merged 3 commits intoapache:masterfrom Mar 13, 2026
Merged
Close SSH channel gracefully on exceptions in port forwarding#885tomaswolf merged 3 commits intoapache:masterfrom
tomaswolf merged 3 commits intoapache:masterfrom
Conversation
When an exception occurs on the forwarding socket, close the SSH channel gracefully.
This test was incorrect since the channel windowing was fixed in commit 0c8f9b2 in 2022. It's actually surprising that the test "worked" somehow for so long, but lately it's been failing more often, in particular on faster machines. The basic problem is that since the channel window fix, AbstcractClientChannel would call LocalWindow.release() when data was written from the channel to the externally provided OutputStream. This would then send back a window adjustment to the server, and hence the server's RemoteWindow would not stay at zero. Apparently the test still succeeded most of the time (probably because of the very low sleep of 1ms in its busy-waiting loop waiting for the window to drop to zero), but it may not have tested what it wanted to test. The solution is to simply not provide an external OutputStream to the channel. Then the channel sets up its own stream, and calls LocalWindow.release() only once the data is really read from invertedOut. That way, the window really drops to zero, and the server will not get window adjustments. Despite this seemingly logical fix the test still was flaky. So ignore it for now. Note that the test claims to test "full TCP/IP buffers", but it actually doesn't. It just tests that an idle timeout is effective and can close the session even when the local window is fully used up.
Using dlcdn.apache.org as URL wasn't a good idea; it carries only the latest 3.8.x and 3.9.x versions. repo.maven.apache.org keeps all versions, so use that.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #879.