Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
wrapperVersion=3.3.4
distributionType=only-script
distributionUrl=https://dlcdn.apache.org/maven/maven-3/3.9.12/binaries/apache-maven-3.9.12-bin.zip
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.12/apache-maven-3.9.12-bin.zip
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

## Bug Fixes

* [GH-879](https://github.com/apache/mina-sshd/issues/879) Close SSH channel gracefully on exception in port forwarding

## New Features

## Potential Compatibility Issues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1034,10 +1034,9 @@ public void sessionClosed(IoSession session) throws Exception {
log.debug("sessionClosed({}) closing channel={} after {} messages - cause={}",
session, channel, messagesCounter, (cause == null) ? null : cause.getClass().getSimpleName());
}
if (channel == null) {
return;
if (channel != null) {
channel.close(false);
}
channel.close(cause != null);
}

@Override
Expand Down
20 changes: 4 additions & 16 deletions sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.io.StreamCorruptedException;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
Expand Down Expand Up @@ -86,6 +84,7 @@
import org.apache.sshd.util.test.EchoShell;
import org.apache.sshd.util.test.EchoShellFactory;
import org.apache.sshd.util.test.TestChannelListener;
import org.junit.Ignore;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.MethodOrderer.MethodName;
Expand All @@ -94,14 +93,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.junit.jupiter.api.Assertions.assertTrue;

/**
* @author <a href="mailto:dev@mina.apache.org">Apache MINA SSHD Project</a>
*/
Expand Down Expand Up @@ -356,6 +347,7 @@ public String toString() {
* read the data, filling the ssh window and the tcp socket - the server session becomes idle, but the ssh
* disconnect message can't be written - the server session is forcibly closed
*/
@Ignore("Unstable test")
@Test
void serverIdleTimeoutWithForce() throws Exception {
final long idleTimeoutValue = TimeUnit.SECONDS.toMillis(5L);
Expand Down Expand Up @@ -401,12 +393,8 @@ public String toString() {

client.start();
try (ClientSession s = createTestClientSession(sshd);
ChannelExec shell = s.createExecChannel("normal");
// Create a pipe that will block reading when the buffer is full
PipedInputStream pis = new PipedInputStream();
PipedOutputStream pos = new PipedOutputStream(pis)) {
ChannelExec shell = s.createExecChannel("normal")) {

shell.setOut(pos);
shell.open().verify(OPEN_TIMEOUT);

assertTrue(channelListener.waitForActiveChannelsChange(5L, TimeUnit.SECONDS),
Expand All @@ -424,7 +412,7 @@ public String toString() {
RemoteWindow wRemote = channel.getRemoteWindow();
for (long totalNanoTime = 0L; wRemote.getSize() > 0;) {
long nanoStart = System.nanoTime();
Thread.sleep(1L);
Thread.sleep(100L);
long nanoEnd = System.nanoTime();
long nanoDuration = nanoEnd - nanoStart;

Expand Down
Loading