JDK-4073756 : java.io.File.renameTo fails on a NFS mounted location
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1,1.2.0,1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: solaris_2.6,windows_95
  • CPU: generic,x86,sparc
  • Submitted: 1997-08-22
  • Updated: 1997-12-19
  • Resolved: 1997-12-19
Related Reports
Duplicate :  
Duplicate :  
Description

Name: joT67522			Date: 08/22/97


This is sample code for a java application. The renameTo method works
on a local file system. When the renameTo is used to rename a file
on the local file system to a NFS mounted path it fails. It does
not throw an exception. This application is running on Solaris.

    final public void Close(){
        if(fevents != null){
           System.out.println("IN CLOSE " + Filename);
           try{
            fevents.close();
            fevents = null;
            if(renamefile == true){
              System.out.println("Rename from " + tempfile);  
              System.out.println("Rename to   " + Filename);
              File tempf = new File(tempfile);
              File newf = new File(Filename);
              if(newf.exists() == true)
                newf.delete();
              tempf.renameTo(newf);
              renamefile = false;
              Filename = null;
            }

           }catch(Exception e){
            System.out.println("Exception Close " + e);
            exceptionLog("CLOSE",e);
           }
        }

        if( sourceData != null){
            try{
             sourceData.close();
             sourceData = null;
            }catch(Exception e){
             exceptionLog("CLOSE",e);
            }

        }
    }

company - Digital Solutions, Inc. , email - ###@###.###
======================================================================

Comments
WORK AROUND Name: joT67522 Date: 08/22/97 ======================================================================
11-06-2004

EVALUATION Rather than throwing an exception, the File.renameTo method returns a boolean to indicate success or failure; the submitted code does not check this value. In this case the renameTo method is failing because, unlike the Unix "mv" command, the File.renameTo method is not specified to copy a file across filesystems when necessary; it will only rename a file within a single filesystem. -- mr@eng 12/18/1997
18-12-1997