现在的位置: 首页 > 综合 > 正文

j2ssh并发性bug

2013年10月01日 ⁄ 综合 ⁄ 共 303字 ⁄ 字号 评论关闭

j2ssh v0.2.9对于并发多个客户端存在问题,总是报List越界

现象

List越界

原因:

SshMsgKexInit类中的sortAlgorithmList,list.remove(pref)时,list为普通ArrayList,并发存取有问题。

 

解决方法

com.sshtools.j2ssh.transport.cipher.SshCipherFactory.java中的static {}中的变量supported初始化改为

        supported = Collections.synchronizedList(new ArrayList(ciphers.keySet()));

这样并发就没问题了。

抱歉!评论已关闭.