apache / apache/mina-sshd

ChannelShell. getInvertedOut() cannot be closed

Open
#334 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
1.1k
Forks
400
Avg merge
5d 1h
Merged PRs (30d)
1

Description

### Version

2.9.2

### Bug description

```java
//close
if (channelShell != null) {
channelShell.close(true);
channelShell.getInvertedOut().close();
}
```

```java
try {
ChannelShell channelShell = clientSession.createShellChannel();
OpenFuture open = channelShell.open();
if (open.await(3000, TimeUnit.SECONDS)) {
if (open.isOpened()) {
byte[] buffer = new byte[1024];
int i;
//TODO ChannelShell关闭,不会让这里停止,甚至channelShell.getInvertedOut().close()都不行
while ((i = channelShell.getInvertedOut().read(buffer)) != -1) {
sendToFrontend(session, Arrays.copyOfRange(buffer, 0, i));
}
} else {
throw new BusinessException("通道打开失败");
}
} else {
throw new BusinessException("连接超时");
}
} catch (IOException e) {
throw new BusinessException("通道创建失败:" + e.getMessage());
}

```

Closing ChannelShell will not stop channelShell. getInvertedOut(), even channelShell. getInvertedOut().close()

### Actual behavior

Closing ChannelShell will not stop channelShell. getInvertedOut(), even channelShell. getInvertedOut().close()

### Expected behavior

Close ChannelShell to close channelShell. getInvertedOut()
```java
try {
ChannelShell channelShell = clientSession.createShellChannel();
OpenFuture open = channelShell.open();
if (open.await(3000, TimeUnit.SECONDS)) {
if (open.isOpened()) {
byte[] buffer = new byte[1024];
int i;
//TODO Closing ChannelShell will not stop channelShell. getInvertedOut(), even channelShell. getInvertedOut().close()
while ((i = channelShell.getInvertedOut().read(buffer)) != -1) {
sendToFrontend(session, Arrays.copyOfRange(buffer, 0, i));
}
} else {
throw new BusinessException("通道打开失败");
}
} else {
throw new BusinessException("连接超时");
}
} catch (IOException e) {
throw new BusinessException("通道创建失败:" + e.getMessage());
}

```

### Relevant log output

_No response_

### Other information

_No response_

Contributor guide

No contributing guide indexed for this repository

Research direction

Reproduce the example using clientSession.createShellChannel(), ChannelShell.open(), getInvertedOut().read(), and ChannelShell.close(true). Start by tracing ChannelShell and its inverted output stream, then verify that closing the channel causes the blocked read to terminate; add or update a regression test if the relevant test location can be identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.