You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "saowu (via GitHub)" <gi...@apache.org> on 2023/03/17 08:10:58 UTC

[GitHub] [mina-sshd] saowu opened a new issue, #334: ChannelShell. getInvertedOut() cannot be closed

saowu opened a new issue, #334:
URL: https://github.com/apache/mina-sshd/issues/334

   ### 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()都不行
               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());
   }
   
   ```
   
   关闭ChannelShell,不会让channelShell.getInvertedOut()停止,甚至关闭channelShell.getInvertedOut()都不行
   
   ### Actual behavior
   
   ChannelShell关闭,不会让channelShell.getInvertedOut()停止,甚至关闭channelShell.getInvertedOut().close()都不行
   
   ### Expected behavior
   
   
   
   关闭ChannelShell,可以关闭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 ChannelShell关闭,不会让这里停止,甚至关闭channelShell.getInvertedOut()都不行
               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_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org