You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rg...@apache.org on 2022/05/29 22:48:24 UTC

[logging-log4j2] branch release-2.x updated: Retry copying if the file is in use

This is an automated email from the ASF dual-hosted git repository.

rgoers pushed a commit to branch release-2.x
in repository https://gitbox.apache.org/repos/asf/logging-log4j2.git


The following commit(s) were added to refs/heads/release-2.x by this push:
     new 84232a6bd6 Retry copying if the file is in use
84232a6bd6 is described below

commit 84232a6bd6e77607fb51f5b3f858426ebfec2275
Author: Ralph Goers <rg...@apache.org>
AuthorDate: Sun May 29 15:48:14 2022 -0700

    Retry copying if the file is in use
---
 .../core/filter/MutableThreadContextMapFilterTest.java      | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/MutableThreadContextMapFilterTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/MutableThreadContextMapFilterTest.java
index 1b88169ec5..671ef5487e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/MutableThreadContextMapFilterTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/filter/MutableThreadContextMapFilterTest.java
@@ -82,7 +82,18 @@ public class MutableThreadContextMapFilterTest implements MutableThreadContextMa
         logger.debug("This is a test");
         Assertions.assertEquals(0, ((ListAppender) app).getEvents().size());
         source = new File("target/test-classes/filterConfig.json").toPath();
-        Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
+        String msg = null;
+        boolean copied = false;
+        for (int i = 0; i < 5 && !copied; ++i) {
+            Thread.sleep(100 + (100 * i));
+            try {
+                Files.copy(source, target, StandardCopyOption.REPLACE_EXISTING);
+                copied = true;
+            } catch (Exception ex) {
+                msg = ex.getMessage();
+            }
+        }
+        assertTrue(copied, "File not copied: " + msg);
         assertNotEquals(fileTime, targetFile.lastModified());
         if (!updated.await(5, TimeUnit.SECONDS)) {
             fail("File update was not detected");