[jcifs] SmbFile.equals() fails when comparing names and numbers
Michael B Allen
ioplex at gmail.com
Fri Nov 12 15:42:27 MST 2010
The ideal behavior would be that if two SmbFiles refer to the same
resource, they are "equal". But that is just a goal. In practice that
ideal behavior is not attainable for a number of reasons.
On Fri, Nov 12, 2010 at 2:21 PM, David Kaelbling
<dkaelbling at blackducksoftware.com> wrote:
> 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
Michael B Allen
Java Active Directory Integration
More information about the jCIFS