Mercurial > hg > openjdk > jigsaw > jdk
changeset 7067:30e30ef6077e
8006645: TEST_BUG: java/nio/file/Files/CopyAndMove.java failing intermittently (sol)
Summary: Fix test failures and update java doc of Files.move
Reviewed-by: alanb, chegar
author | dxu |
---|---|
date | Fri, 01 Mar 2013 14:12:59 -0800 |
parents | 1ca712765acb |
children | f08ad5938709 |
files | src/share/classes/java/nio/file/Files.java test/java/nio/file/Files/CopyAndMove.java |
diffstat | 2 files changed, 23 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/share/classes/java/nio/file/Files.java Fri Mar 01 16:15:23 2013 -0500 +++ b/src/share/classes/java/nio/file/Files.java Fri Mar 01 14:12:59 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -1152,7 +1152,7 @@ * and file system dependent and therefore unspecified. Minimally, the * {@link BasicFileAttributes#lastModifiedTime last-modified-time} is * copied to the target file if supported by both the source and target - * file store. Copying of file timestamps may result in precision + * file stores. Copying of file timestamps may result in precision * loss. </td> * </tr> * <tr> @@ -1169,12 +1169,12 @@ * implementation specific options. * * <p> Copying a file is not an atomic operation. If an {@link IOException} - * is thrown then it possible that the target file is incomplete or some of - * its file attributes have not been copied from the source file. When the - * {@code REPLACE_EXISTING} option is specified and the target file exists, - * then the target file is replaced. The check for the existence of the file - * and the creation of the new file may not be atomic with respect to other - * file system activities. + * is thrown, then it is possible that the target file is incomplete or some + * of its file attributes have not been copied from the source file. When + * the {@code REPLACE_EXISTING} option is specified and the target file + * exists, then the target file is replaced. The check for the existence of + * the file and the creation of the new file may not be atomic with respect + * to other file system activities. * * <p> <b>Usage Example:</b> * Suppose we want to copy a file into a directory, giving it the same file @@ -1279,15 +1279,16 @@ * <p> An implementation of this interface may support additional * implementation specific options. * - * <p> Where the move requires that the file be copied then the {@link - * BasicFileAttributes#lastModifiedTime last-modified-time} is copied to the - * new file. An implementation may also attempt to copy other file - * attributes but is not required to fail if the file attributes cannot be - * copied. When the move is performed as a non-atomic operation, and a {@code - * IOException} is thrown, then the state of the files is not defined. The - * original file and the target file may both exist, the target file may be - * incomplete or some of its file attributes may not been copied from the - * original file. + * <p> Moving a file will copy the {@link + * BasicFileAttributes#lastModifiedTime last-modified-time} to the target + * file if supported by both source and target file stores. Copying of file + * timestamps may result in precision loss. An implementation may also + * attempt to copy other file attributes but is not required to fail if the + * file attributes cannot be copied. When the move is performed as + * a non-atomic operation, and an {@code IOException} is thrown, then the + * state of the files is not defined. The original file and the target file + * may both exist, the target file may be incomplete or some of its file + * attributes may not been copied from the original file. * * <p> <b>Usage Examples:</b> * Suppose we want to rename a file to "newname", keeping the file in the
--- a/test/java/nio/file/Files/CopyAndMove.java Fri Mar 01 16:15:23 2013 -0500 +++ b/test/java/nio/file/Files/CopyAndMove.java Fri Mar 01 14:12:59 2013 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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 @@ -22,7 +22,7 @@ */ /* @test - * @bug 4313887 6838333 6917021 7006126 6950237 + * @bug 4313887 6838333 6917021 7006126 6950237 8006645 * @summary Unit test for java.nio.file.Files copy and move methods * @library .. * @build CopyAndMove PassThroughFileSystem @@ -37,6 +37,7 @@ import java.nio.file.attribute.*; import java.io.*; import java.util.*; +import java.util.concurrent.TimeUnit; public class CopyAndMove { static final Random rand = new Random(); @@ -94,8 +95,8 @@ // check last modified time if not a symbolic link if (!attrs1.isSymbolicLink()) { - long time1 = attrs1.lastModifiedTime().toMillis(); - long time2 = attrs2.lastModifiedTime().toMillis(); + long time1 = attrs1.lastModifiedTime().to(TimeUnit.SECONDS); + long time2 = attrs2.lastModifiedTime().to(TimeUnit.SECONDS); if (time1 != time2) { System.err.format("File time for %s is %s\n", attrs1.fileKey(), attrs1.lastModifiedTime());