This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository jtimer. See https://gitlab.nuiton.org/chorem/jtimer.git commit 5bc154cd94c216fb19db9b5a9918f42f4d14542b Author: CHRE <CHATELLIER@codelutin.com> Date: Thu May 26 12:07:14 2016 +0200 Fix test failing on windows --- .../java/org/chorem/jtimer/io/AbstractSaver.java | 43 ++++++++++++---------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/src/main/java/org/chorem/jtimer/io/AbstractSaver.java b/src/main/java/org/chorem/jtimer/io/AbstractSaver.java index 7fc8b9d..f8d0ed7 100644 --- a/src/main/java/org/chorem/jtimer/io/AbstractSaver.java +++ b/src/main/java/org/chorem/jtimer/io/AbstractSaver.java @@ -2,7 +2,7 @@ * #%L * jTimer * %% - * Copyright (C) 2009 - 2011 CodeLutin, Chatellier Eric + * Copyright (C) 2009 - 2016 CodeLutin, Chatellier Eric * %% * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as @@ -24,6 +24,8 @@ package org.chorem.jtimer.io; import java.io.File; import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.StandardCopyOption; import java.util.TimerTask; import org.apache.commons.io.FileUtils; @@ -32,12 +34,12 @@ import org.apache.commons.logging.LogFactory; /** * Abstract saver class. - * + * * Contains methods that can be used by various savers. - * + * * @author chatellier * @version $Revision$ - * + * * Last update : $Date$ * By : $Author$ */ @@ -51,12 +53,12 @@ public abstract class AbstractSaver extends TimerTask implements Saver { /** * Make to backup of file if exists. - * + * * Copy file to filename + ".tmp" - * + * * @param file file to backup * @return backup file or {@code null} if input file doesn't exist - * @throws IOException + * @throws IOException */ protected File makeBackupFile(File file) throws IOException { @@ -68,8 +70,7 @@ public abstract class AbstractSaver extends TimerTask implements Saver { File backupFile = new File(file.getAbsoluteFile() + BACKUP_EXTENSION); if (log.isDebugEnabled()) { - log.debug("Backuping file " + file.getName() + " to " - + backupFile.getName()); + log.debug("Backuping file " + file.getName() + " to " + backupFile.getName()); } backupFile.delete(); @@ -79,7 +80,7 @@ public abstract class AbstractSaver extends TimerTask implements Saver { /** * Rename backup file to original file name; - * + * * @param backupFile backup file * @return if backup file has been restored */ @@ -87,29 +88,31 @@ public abstract class AbstractSaver extends TimerTask implements Saver { String fileName = backupFile.getAbsolutePath(); if (!fileName.endsWith(BACKUP_EXTENSION)) { - throw new IllegalArgumentException("Not a valid backup file" - + backupFile); + throw new IllegalArgumentException("Not a valid backup file" + backupFile); } - fileName = fileName.substring(0, fileName.length() - - BACKUP_EXTENSION.length()); + fileName = fileName.substring(0, fileName.length() - BACKUP_EXTENSION.length()); File file = new File(fileName); if (log.isDebugEnabled()) { - log.debug("Renaming " + backupFile.getName() + " to " - + file.getName()); + log.debug("Renaming " + backupFile.getName() + " to " + file.getName()); } - //file.delete(); - boolean done = backupFile.renameTo(file); + boolean done; + try { + Files.move(backupFile.toPath(), file.toPath(), StandardCopyOption.REPLACE_EXISTING); + done = true; + } catch (IOException ex) { + done = false; + } return done; } /** * Delete backup file. - * + * * This function NEVER throw IOException. - * + * * @param backupFile backup file (can be {@code null}) */ protected void deleteBackupFile(File backupFile) { -- To stop receiving notification emails like this one, please contact chorem.org SCM administrator <admin+scm@chorem.org>.