--- old/src/java.xml.bind/share/classes/com/sun/xml/internal/org/jvnet/mimepull/WeakDataFile.java 2015-10-16 12:58:02.000000000 +0200 +++ new/src/java.xml.bind/share/classes/com/sun/xml/internal/org/jvnet/mimepull/WeakDataFile.java 2015-10-16 12:58:02.000000000 +0200 @@ -1,5 +1,5 @@ /* - * 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 @@ -25,6 +25,9 @@ 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; @@ -133,10 +136,12 @@ 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) {