[jcifs] Re: jcifs.smb.Dfs bugs

Ronny Schuetz Usenet.r96 at gishpuppy.com
Mon Apr 28 14:34:06 GMT 2008


Hi Mike,

>> Looks like my previous assumption was totally wrong, I apologize. I was 
>> misled by the null values returned by SmbFile#getDfsPath() just before 
>> renameTo() failed. Adding an exists() calls directly before renameTo() 
>> as discussed earlier in this list helped here for most of the cases.
> 
> Is that a bug I said I was going to fix. What's the approx. date and
> Subject of the thread?

Yes. See http://article.gmane.org/gmane.network.samba.java/6578/

>> But it looks like jCIFS does not react, if a replica is just taken 
>> offline or removed from the DFS configuration as long as the share 
>> (previously) configured as link is still accessible. Dfs#resolve() 
>> returns the right share to use (i.e. the remaining one), but even new 
>> SmbFile objects created using the DFS root URL continue to access the 
>> share which has been taken offline / removed.
> 
> It should react - with an exception. Does it?

No, it didn't and there was no exception. However, after further 
investigation I believe the issue wasn't caused by jCIFS at all but by 
Windows - very likely due to the "strange" setup (two shares on the same 
directory); after creating two separate directories - one for each share 
- jCIFS fails over fine, the same is true for using a directory and 
junction to this directory (to simulate the replication).

By the way, I found some minor other issues SmbFile and SmbTransport. 
Maybe you want to include into the code base:

SmbFile#getDfsPath():

Changes:
  - one slash was missing in "smb://"
  - "/" was appended to path even if it already had one at the end

New code:

     public String getDfsPath() throws SmbException {
         resolveDfs(null);

         if( dfsReferral == null ) {
             return null;
         }

         String path = "smb://" + dfsReferral.server + "/" +
dfsReferral.share + unc;
         path = path.replace( '\\', '/' );
         if (isDirectory() && !path.endsWith("/")) {
             path += '/';
         }
         return path;
     }

SmbTransport#checkStatus():

Changes:

- Avoid ArrayIndexOutOfBoundsException in case all referred shares are 
offline

Replace

SmbFile.dfs.insert(req.path, drs[0]);
throw drs[0];

with

if(drs.length == 0)
{
  throw new SmbException( resp.errorCode, null );
}
else
{
  SmbFile.dfs.insert(req.path, drs[0]);
  throw drs[0];
}

Best regards,
Ronny






More information about the jcifs mailing list