FULL PRODUCT VERSION :
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
A Windows server configured to run as a DFS server
Another server with CIFS shares
A Client machine running the Java code.
A DESCRIPTION OF THE PROBLEM :
When attempting to retrieve underlying file system information about the a CIFS share that happens to be a Windows DFS link from a java.nio.file.FileStore, such as size or free space. instead of retrieving the file system information about the target of the DFS link, information about the C: drive of the server hosting the DFS share is returned instead.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On a Windows server create a normal CIFS share. e.g \\server\someShare\
On another Windows server configure a DFS link to point to that CIFS share. \\exampledomain.com\dfsLink
On a third machine in java attempt to get information about the CIFS share \\server\someShare\ using a java.nio.file.FileStore.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The java.nio.file.FileStore should show information about the target of the DFS link not the C drive of the server hosting that link.
ACTUAL -
The java.nio.file.FileStore gives information ( size, freespace etc ) from the C: drive of the server hosting the DFS link.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class DFSTest {
public static void main( final String[] args ) {
Path dfsServerPath = Paths.get( "\\\\dfsServer\\c$\\" );
Path dfsSharePath = Paths.get( "\\\\exampledomain.com\\dfsLink\\" );
Path targetOfDFSShare = Paths.get("\\\\server\\someShare\\");
try {
long dfsServerPathSize = getTotalSizeOfPath( dfsServerPath );
long dfsSharePathSize = getTotalSizeOfPath( dfsSharePath );
long targetOfDFSShareSize = getTotalSizeOfPath( targetOfDFSShare );
long dfsServerPathFreeSpace = getFreeSpace( dfsServerPath );
long dfsSharePathFreeSpace = getFreeSpace( dfsSharePath );
long targetOfDFSShareFreeSpace = getFreeSpace( targetOfDFSShare );
System.out.println( "DFS Server C Drive Size : " + dfsServerPathSize + " DFS Share Size : " + dfsSharePathSize + " Target of DFS Share Size : " + targetOfDFSShareSize );
System.out.println( "DFS Server C Drive Free Space : " + dfsServerPathFreeSpace +
" DFS Share Free Space : " + dfsSharePathFreeSpace + " Target of DFS Share Free Space : " + targetOfDFSShareFreeSpace );
} catch ( IOException e ) {
e.printStackTrace();
}
}
/**
* Returns the total size of the filesystem under the path.
* @param path the path whose size is returned.
* @return the total size of the filesystem.
* @throws IOException
*/
private static long getTotalSizeOfPath( Path path ) throws IOException {
FileStore dfsFS = Files.getFileStore( path );
return dfsFS.getTotalSpace();
}
/**
* Returns the free space of the filesystem under the path.
* @param path the path whose free space is returned.
* @return the free space of the filesystem.
* @throws IOException
*/
private static long getFreeSpace( Path path ) throws IOException {
FileStore dfsFS = Files.getFileStore( path );
return dfsFS.getUnallocatedSpace();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The only work around is to write code in C to call the windows DFS libraries to retrieve this information.
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]
EXTRA RELEVANT SYSTEM CONFIGURATION :
A Windows server configured to run as a DFS server
Another server with CIFS shares
A Client machine running the Java code.
A DESCRIPTION OF THE PROBLEM :
When attempting to retrieve underlying file system information about the a CIFS share that happens to be a Windows DFS link from a java.nio.file.FileStore, such as size or free space. instead of retrieving the file system information about the target of the DFS link, information about the C: drive of the server hosting the DFS share is returned instead.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
On a Windows server create a normal CIFS share. e.g \\server\someShare\
On another Windows server configure a DFS link to point to that CIFS share. \\exampledomain.com\dfsLink
On a third machine in java attempt to get information about the CIFS share \\server\someShare\ using a java.nio.file.FileStore.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The java.nio.file.FileStore should show information about the target of the DFS link not the C drive of the server hosting that link.
ACTUAL -
The java.nio.file.FileStore gives information ( size, freespace etc ) from the C: drive of the server hosting the DFS link.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.nio.file.FileStore;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
public class DFSTest {
public static void main( final String[] args ) {
Path dfsServerPath = Paths.get( "\\\\dfsServer\\c$\\" );
Path dfsSharePath = Paths.get( "\\\\exampledomain.com\\dfsLink\\" );
Path targetOfDFSShare = Paths.get("\\\\server\\someShare\\");
try {
long dfsServerPathSize = getTotalSizeOfPath( dfsServerPath );
long dfsSharePathSize = getTotalSizeOfPath( dfsSharePath );
long targetOfDFSShareSize = getTotalSizeOfPath( targetOfDFSShare );
long dfsServerPathFreeSpace = getFreeSpace( dfsServerPath );
long dfsSharePathFreeSpace = getFreeSpace( dfsSharePath );
long targetOfDFSShareFreeSpace = getFreeSpace( targetOfDFSShare );
System.out.println( "DFS Server C Drive Size : " + dfsServerPathSize + " DFS Share Size : " + dfsSharePathSize + " Target of DFS Share Size : " + targetOfDFSShareSize );
System.out.println( "DFS Server C Drive Free Space : " + dfsServerPathFreeSpace +
" DFS Share Free Space : " + dfsSharePathFreeSpace + " Target of DFS Share Free Space : " + targetOfDFSShareFreeSpace );
} catch ( IOException e ) {
e.printStackTrace();
}
}
/**
* Returns the total size of the filesystem under the path.
* @param path the path whose size is returned.
* @return the total size of the filesystem.
* @throws IOException
*/
private static long getTotalSizeOfPath( Path path ) throws IOException {
FileStore dfsFS = Files.getFileStore( path );
return dfsFS.getTotalSpace();
}
/**
* Returns the free space of the filesystem under the path.
* @param path the path whose free space is returned.
* @return the free space of the filesystem.
* @throws IOException
*/
private static long getFreeSpace( Path path ) throws IOException {
FileStore dfsFS = Files.getFileStore( path );
return dfsFS.getUnallocatedSpace();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
The only work around is to write code in C to call the windows DFS libraries to retrieve this information.