Skip to content

Commit 5b21302

Browse files
committed
Fix failing tests
1 parent 22ad6b2 commit 5b21302

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

log4j-core-test/src/test/java/org/apache/logging/log4j/core/appender/rolling/RollingAppenderTempCompressedFilePatternTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package org.apache.logging.log4j.core.appender.rolling;
1818

1919
import static org.assertj.core.api.Assertions.assertThat;
20+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
2021

2122
import java.io.InputStream;
2223
import java.nio.charset.Charset;
@@ -83,7 +84,7 @@ void testAppender(final LoggerContext context) throws Exception {
8384
AtomicInteger fileCount = new AtomicInteger();
8485
AtomicInteger gzippedFileCount = new AtomicInteger();
8586
try (final DirectoryStream<Path> files = Files.newDirectoryStream(logsDir)) {
86-
assertThat(files).allSatisfy(file -> {
87+
files.forEach(file -> assertDoesNotThrow(() -> {
8788
fileCount.incrementAndGet();
8889
final boolean isGzipped = file.getFileName().toString().endsWith(".gz");
8990
if (isGzipped) {
@@ -97,7 +98,7 @@ void testAppender(final LoggerContext context) throws Exception {
9798
lines.forEach(messages::remove);
9899
}
99100
}
100-
});
101+
}));
101102
}
102103
assertThat(messages).as("Lost messages").isEmpty();
103104
assertThat(fileCount).as("Log file file count").hasValueGreaterThan(16);

log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,14 @@ public DefaultRolloverStrategy build() {
147147
// The config object can be null only in tests
148148
final Configuration configuration = config != null ? config : new NullConfiguration();
149149
final StrSubstitutor nonNullStrSubstitutor = configuration.getStrSubstitutor();
150+
final Map<String, ?> compressionOptions = compressionLevel != null
151+
? Map.of(CompressActionFactory.COMPRESSION_LEVEL, compressionLevel)
152+
: Map.of();
150153
return new DefaultRolloverStrategy(
151154
minIndex,
152155
maxIndex,
153156
useMax,
154-
Map.of(CompressActionFactory.COMPRESSION_LEVEL, compressionLevel),
157+
compressionOptions,
155158
nonNullStrSubstitutor,
156159
customActions,
157160
stopCustomActionsOnError,

log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ public DirectWriteRolloverStrategy build() {
9696
maxIndex = DEFAULT_MAX_FILES;
9797
}
9898
}
99+
final Map<String, ?> compressionOptions = compressionLevel != null
100+
? Map.of(CompressActionFactory.COMPRESSION_LEVEL, compressionLevel)
101+
: Map.of();
99102
return new DirectWriteRolloverStrategy(
100103
maxIndex,
101-
Map.of(CompressActionFactory.COMPRESSION_LEVEL, compressionLevel),
104+
compressionOptions,
102105
config.getStrSubstitutor(),
103106
customActions,
104107
stopCustomActionsOnError,

0 commit comments

Comments
 (0)