You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by gg...@apache.org on 2016/08/07 18:19:38 UTC

logging-log4j2 git commit: Do not go through the delete retry loop if a file or folder does not exist.

Repository: logging-log4j2
Updated Branches:
  refs/heads/master cc284d183 -> a3b5f73a6


Do not go through the delete retry loop if a file or folder does not
exist.

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/a3b5f73a
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/a3b5f73a
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/a3b5f73a

Branch: refs/heads/master
Commit: a3b5f73a6e08e9d91ba1a82f22727213c7382e46
Parents: cc284d1
Author: Gary Gregory <gg...@apache.org>
Authored: Sun Aug 7 11:19:37 2016 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Sun Aug 7 11:19:37 2016 -0700

----------------------------------------------------------------------
 .../apache/logging/log4j/junit/CleanFiles.java  | 26 +++++++++++---------
 .../logging/log4j/junit/CleanFolders.java       | 24 +++++++++---------
 2 files changed, 27 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a3b5f73a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
index 5de9c63..1021bf1 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFiles.java
@@ -47,19 +47,21 @@ public class CleanFiles extends AbstractExternalFileCleaner {
     @Override
     protected void clean() {
         for (final File file : getFiles()) {
-            for (int i = 0; i < MAX_TRIES; i++) {
-                try {
-                    if (Files.deleteIfExists(file.toPath())) {
-                        // Break from MAX_TRIES and move on to the next file.
-                        break;
+            if (file.exists()) {
+                for (int i = 0; i < MAX_TRIES; i++) {
+                    try {
+                        if (Files.deleteIfExists(file.toPath())) {
+                            // Break from MAX_TRIES and move on to the next file.
+                            break;
+                        }
+                    } catch (final IOException e) {
+                        Assert.fail(file + ": " + e.toString());
+                    }
+                    try {
+                        Thread.sleep(200);
+                    } catch (final InterruptedException ignored) {
+                        // ignore
                     }
-                } catch (final IOException e) {
-                    Assert.fail(file + ": " + e.toString());
-                }
-                try {
-                    Thread.sleep(200);
-                } catch (final InterruptedException ignored) {
-                    // ignore
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a3b5f73a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java
index a3c84c0..6a2f8d6 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/junit/CleanFolders.java
@@ -55,18 +55,20 @@ public class CleanFolders extends AbstractExternalFileCleaner {
         Map<Path, IOException> failures = new HashMap<>();
 
         for (final File folder : getFiles()) {
-            final Path path = folder.toPath();
-            for (int i = 0; i < MAX_TRIES; i++) {
-                try {
-                    cleanFolder(path);
-                    if (failures.containsKey(path)) {
-                        failures.remove(path);
+            if (folder.exists()) {
+                final Path path = folder.toPath();
+                for (int i = 0; i < MAX_TRIES; i++) {
+                    try {
+                        cleanFolder(path);
+                        if (failures.containsKey(path)) {
+                            failures.remove(path);
+                        }
+                        // break from MAX_TRIES and goes to the next folder
+                        break;
+                    } catch (final IOException e) {
+                        // We will try again.
+                        failures.put(path, e);
                     }
-                    // break from MAX_TRIES and goes to the next folder
-                    break;
-                } catch (final IOException e) {
-                    // We will try again.
-                    failures.put(path, e);
                 }
             }
         }