< prev index next >

src/java.xml.bind/share/classes/com/sun/xml/internal/org/jvnet/mimepull/WeakDataFile.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -23,10 +23,13 @@
  * questions.
  */
 
 package com.sun.xml.internal.org.jvnet.mimepull;
 
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
 import java.util.concurrent.TimeUnit;
 
 import java.io.File;
 import java.io.IOException;
 import java.io.RandomAccessFile;

@@ -131,14 +134,16 @@
             LOGGER.log(Level.FINE, "Moving file={0} to={1}", new Object[]{file, f});
         }
         refList.remove(this);
         try {
             raf.close();
-            boolean renamed = file.renameTo(f);
+            Path target = Files.move(file.toPath(), f.toPath(), StandardCopyOption.REPLACE_EXISTING);
+            boolean renamed = f.toPath().equals(target);
             if (!renamed) {
                 if (LOGGER.isLoggable(Level.INFO)) {
-                    LOGGER.log(Level.INFO, "File {0} was not moved to {1}", new Object[] {file.getAbsolutePath(), f.getAbsolutePath()});
+                    throw new MIMEParsingException("File " + file.getAbsolutePath() +
+                            " was not moved to " + f.getAbsolutePath());
                 }
             }
         } catch(IOException ioe) {
             throw new MIMEParsingException(ioe);
         }
< prev index next >