[jcifs] SmbFile.equals() fails when comparing names and numbers

David Kaelbling dkaelbling at blackducksoftware.com
Fri Nov 12 12:21:09 MST 2010


Writing unit tests for my code, I'm having some troubles that look like
they're caused by SmbFile.equals() misbehaving.  The javadoc says that
variations in server name don't matter as long as they resolve to the
same IP address.  But SmbFiles.equals() returns false for these two
    // InetAddress localAddr = InetAddress.getLocalHost();
    new SmbFile("smb://" + localAddr.getCanonicalHostName() + "/")
    new SmbFile("smb://" + localAddr.getHostAddress() + "/")

Poking about in the debugger SmbFile.equals() decides that the canonical
paths are equal, and delegates to UniAddress.equals(), which in turn
tries to compare the addr fields.  Which fails, because the first addr
is an Inet4Address, while the second is an NbtAddress.

The two objects have the same value for their "address" member, but
because the types are disjoint they aren't compared.

Have I misread the spec?  It seems like this comparison should have

    - David

PS: My machine is not exporting any shares, if that matters.

David Kaelbling
Senior Software Engineer
Black Duck Software, Inc.

dkaelbling at blackducksoftware.com
T +1.781.810.2041
F +1.781.891.5145


More information about the jCIFS mailing list