JDK-4414890 : (spec) document that File.renameTo() can't rename to NFS-mounted filesystems
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.3.1
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2001-02-13
  • Updated: 2005-02-02
  • Resolved: 2005-02-02
Related Reports
Duplicate :  
Description
I was debugging an application that uses the renameTo() method of the File class in the java io package.  The problem was that in certain situations, the application uses renameTo() to rename a file to a location on a different NFS mounted filesystem.  However, the renameTo method does not support this. 

I spent a lot of time debugging this until I realized that renameTo() doesn't support renaming a file to a location on a different filesystem.  I assume others have expected renameTo() to support this because of bug 4073756.  I think it would be a good idea to mention this in the javadocs on the web.  That is, if there are no plans on adding more functionality to the renameTo() method.

Comments
EVALUATION Since we can not guarantee that File.renameTo will be successful, you need to check the return value. The following clarification was made to the specification for File.renameTo during Tiger (1.5) development: Many aspects of the behavior of this method are inherently platform-dependent: The rename operation might not be able to move a file from one filesystem to another, it might not be atomic, and it might not succeed if a file with the destination abstract pathname already exists. The return value should always be checked to make sure that the rename operation was successful. Closing bug as duplicate of 4167147. ###@###.### 2005-2-02 22:26:46 GMT
02-02-2005