[jcifs] A bug when looping through IPs

Michael B Allen ioplex at gmail.com
Thu May 8 02:44:06 MDT 2014

On Thu, Feb 20, 2014 at 8:30 AM, Xie, Sean <Sean.Xie at finra.org> wrote:
> Hi JCIFS support,
> We are using latest jcifs lib for our internal app and there was randomly an
> error “A duplicate name …” happened. After tracing into the code, I found
> there is a private method doConnect() in SmbFile class. It is called by a
> loop if there are multiple addresses obtained from the name.  And at
> SmbFile.java line 894 – 899, the code is checking if tree is null, if not it
> will re-use the tree.session, so every loop it is using the first address
> because the tree.session is alive. Therefore, in the case if the first one
> from list of the addresses is failed, the loop will not get the next
> address.
> Do you think there is any way to release a fix? Or we can do our own fork?

Hi Sean,

Note that there is logic to reuse the same server once one has been
verified to work at least in some way. This principal is called
"server stickyness" and it is important for data consistency. So it
may be that there is actually no flaw in the logic you're citing. You
would need to be a little clearer about what you think is wrong before
I could look at this problem.

Or create a fork that illustrates how you think it should work. I
strongly encourage people to create their own fork of JCIFS. I think
that Linux / github style of development is much superior to version
control systems. People can immediately try your fork and if it gets
attention then we know it's something to look at possibly integrate
into the official version.


Michael B Allen
Java Active Directory Integration

More information about the jCIFS mailing list