At my company I've recently run into a bug in Commons-IO 2.2 using the 
FileUtils.moveFile(File, File) and FileUtils.copyFile(File, File) method in 
Java 5.

The bug causes Java to hang when we attempt to move any >30 MB file across 
physical devices on OpenVMS.  The process hangs after OpenVMS has allocated the 
appropriate file space and never writes any content to the file.  The process 
will not error and has to be interrupted to exit.

Upon exit, some cache must get flushed, because exactly 31440673 bytes are then 
written to the destination file, as long as the source file is larger than 
that. These methods work fine on smaller files  (< 30 MB) in the same 
environment.  I suspect that this is the result of attempting to first rename 
the source file to the destination file, which is unsupported across physical 
devices on OpenVMS, but the utility falls back on a copy/delete should the 
rename fail.  Moving small files in the same manner has never caused us an 
issue.

Is there anyone who has run into anything similar or know of any caveats using 
Apache Commons in OpenVms for FileUtils?

In the meantime, we've got a workaround in the format (with better exception 
handling):
inStream = FileUtils.openInputStream(srcFile);
      outStream = FileUtils.openOutputStream(destFile);
      IOUtils.copy(inStream, outStream);
      inStream.close()
outStream.close()
srcFile.delete()

One weird thing is that the internal copy method in FileUtils (doCopyFile(final 
File srcFile, final File destFile, final boolean preserveFileDate)) does 
something very similar, so I would have expected that my workaround would have 
hung as well.

Thank you,
Jordan Grant


Reply via email to