Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastjson从1.2.83升级到兼容版本2.0.39序列化ChannelSftp导致后续sftp命令无法执行 #2202

Closed
cheers512 opened this issue Jan 19, 2024 · 5 comments
Labels
bug Something isn't working fixed
Milestone

Comments

@cheers512
Copy link

问题描述

channelsftp对象序列化后,后续执行sftp的如cd、put命令会一直卡住

环境信息

请填写以下信息:

  • JDK信息: [e.g.:Openjdk 1.8.0_144]
  • 版本信息:[e.g.:Fastjson2.0.39 1.X兼容版本]

重现步骤

依赖版本

com.jcraft
jsch
0.1.55

com.alibaba fastjson 2.0.39 ```java JSch jsch = new JSch(); Session sshSession = jsch.getSession(customUserName, customHost, customPort); java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); sshSession.setConfig(config); // sshSession.setConfig("StrictHostKeyChecking", "no"); sshSession.setPassword(customPassword); sshSession.connect(5000); ChannelSftp channelSftp = (ChannelSftp) sshSession.openChannel("sftp"); channelSftp.connect(5000); log.info("连接成功",JSON.toJSONString(channelSftp)); channelSftp.cd("/test");

期待的正确结果

sftp命令能够正常执行

@cheers512 cheers512 added the bug Something isn't working label Jan 19, 2024
@cheers512
Copy link
Author

1705650336798

@cheers512
Copy link
Author

2

@rowstop
Copy link
Contributor

rowstop commented Jan 20, 2024

用法貌似不太合适,日志这种地方可以尝试手动拼接自己想看到的参数,转 JSON 没必要。
没开启 filedbase 默认基于 get 序列化貌似sftp.getInputStream()影响到了,你在 cd前 getInputStream 会导致一样的问题
你可以通过这种方式,排除inputStream,但建议把所有输入输出流全部排除

        PropertyPreFilter propertyPreFilter = (writer,obj,name)-> !"inputStream".equals(name);
        JSON.toJSONString(sftp,propertyPreFilter);

@wenshao
Copy link
Member

wenshao commented Jan 21, 2024

https://oss.sonatype.org/content/repositories/snapshots/com/alibaba/fastjson2/fastjson2/2.0.46-SNAPSHOT/
兼容问题已修复,忽略所有的InputStream Getter,请帮忙用2.0.46-SNAPSHOT版本验证,正式版本预计在3月初发布。

@wenshao wenshao added this to the 2.0.46 milestone Jan 21, 2024
@wenshao wenshao added the fixed label Jan 21, 2024
@wenshao
Copy link
Member

wenshao commented Jan 29, 2024

https://github.com/alibaba/fastjson2/releases/tag/2.0.46
请用新版本

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

3 participants