Retry copying if the file is in use
@@ -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();
+ 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");
