[ 
https://issues.apache.org/jira/browse/SSHD-1209?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17401781#comment-17401781
 ] 

Susmit Sarkar commented on SSHD-1209:
-------------------------------------

Welcome to the community

The version is 2.7.0 it's mentioned above.

You can have a look at this class

[https://github.com/apache/mina-sshd/blob/2fc98f7a21a7b83d2b2bc72d48a2194caa7f8fd1/sshd-contrib/src/main/java/org/apache/sshd/contrib/server/subsystem/sftp/DetailedSftpErrorStatusDataHandler.java]

only difference is I have implemented is adding few more interfaces:

ChannelSessionAware, AsyncCommandErrorStreamAware, CommandDirectErrorStreamAware

to write any sftp related exception to the command line output, and have 
overrwritten few default methods

resolveErrorMessage() and setIoErrorStream(IoOutputStream errStream) 

 

 

> Write to error stream for custom exception is appending a extra word at the 
> beginning
> -------------------------------------------------------------------------------------
>
>                 Key: SSHD-1209
>                 URL: https://issues.apache.org/jira/browse/SSHD-1209
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.7.0
>            Reporter: Susmit Sarkar
>            Priority: Major
>         Attachments: image-2021-08-19-12-50-01-922.png
>
>
> Hello Team,
>  
> We have a class as below
>  
> {code:java}
> DetailedSftpErrorStatusDataHandler implements SftpErrorStatusDataHandler, 
> ChannelSessionAware, DetailedSftpErrorStatusDataHandler implements 
> SftpErrorStatusDataHandler, ChannelSessionAware, 
> AsyncCommandErrorStreamAware, CommandDirectErrorStreamAware {
> {code}
> and we have overridden the :
>  
> resolveErrorMessage and setIoErrorStream(IoOutputStream errStream) 
> {code:java}
>  @Override
>  public void setIoErrorStream(IoOutputStream errStream) { 
>      this.errStream = errStream;
>  }
> {code}
> finally we are writing to the error stream:
> {code:java}
> private void writeMsgToErrorStream(String refinedUserExitMessage) {
>     ByteArrayBuffer buf = new ByteArrayBuffer();
>     buf.putString(refinedUserExitMessage + 
> System.getProperty("line.separator")); 
>     try { if (errStream != null) { 
>         errStream.writeBuffer(buf); 
>           }
>     } catch (Exception e) { 
>     }
>  }
> {code}
> Once the data is written to error stream we are gettig proper message to the 
> console:
> !image-2021-08-19-12-50-01-922.png!
> But there is an extra charater getting appended at the first character *<* 
> Utils.java ....
> I have no idea from where this *<* is coming from, and that changes with the 
> first character like if it is P it would be *>, when starting with S it gets 
> appended with Z*
> Any help will be appreciated.
> Thanks,
> Susmit
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to