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 2020/11/09 16:21:54 UTC

[logging-log4j2] branch release-2.x updated: This test always fails on Windows if you do not close the RandomAccessFileManager.

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

ggregory 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 6797db0  This test always fails on Windows if you do not close the RandomAccessFileManager.
6797db0 is described below

commit 6797db0e63a5b78b45947f53b93966b5a844c79b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 9 11:21:47 2020 -0500

    This test always fails on Windows if you do not close the
    RandomAccessFileManager.
---
 .../log4j/core/appender/RandomAccessFileManagerTest.java      | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
index 6227f37..84e365e 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/appender/RandomAccessFileManagerTest.java
@@ -132,10 +132,11 @@ public class RandomAccessFileManagerTest {
         }
         assertEquals(bytes.length, file.length(), "all flushed to disk");
 
-        final RandomAccessFileManager manager = RandomAccessFileManager.getFileManager(
-                file.getAbsolutePath(), isAppend, true, RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null, null);
-        manager.write(bytes, 0, bytes.length, true);
-        final int expected = bytes.length * 2;
-        assertEquals(expected, file.length(), "appended, not overwritten");
+        try (final RandomAccessFileManager manager = RandomAccessFileManager.getFileManager(file.getAbsolutePath(),
+                isAppend, true, RandomAccessFileManager.DEFAULT_BUFFER_SIZE, null, null, null)) {
+            manager.write(bytes, 0, bytes.length, true);
+            final int expected = bytes.length * 2;
+            assertEquals(expected, file.length(), "appended, not overwritten");
+        }
     }
 }