Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ppkarwasz committed Sep 6, 2024
1 parent c25ca57 commit 3d35565
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.apache.logging.log4j.core.appender.rolling;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;

import java.io.InputStream;
import java.nio.charset.Charset;
Expand Down Expand Up @@ -83,7 +84,7 @@ void testAppender(final LoggerContext context) throws Exception {
AtomicInteger fileCount = new AtomicInteger();
AtomicInteger gzippedFileCount = new AtomicInteger();
try (final DirectoryStream<Path> files = Files.newDirectoryStream(logsDir)) {
assertThat(files).allSatisfy(file -> {
files.forEach(file -> assertDoesNotThrow(() -> {
fileCount.incrementAndGet();
final boolean isGzipped = file.getFileName().toString().endsWith(".gz");
if (isGzipped) {
Expand All @@ -97,7 +98,7 @@ void testAppender(final LoggerContext context) throws Exception {
lines.forEach(messages::remove);
}
}
});
}));
}
assertThat(messages).as("Lost messages").isEmpty();
assertThat(fileCount).as("Log file file count").hasValueGreaterThan(16);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,14 @@ public DefaultRolloverStrategy build() {
// The config object can be null only in tests
final Configuration configuration = config != null ? config : new NullConfiguration();
final StrSubstitutor nonNullStrSubstitutor = configuration.getStrSubstitutor();
final Map<String, ?> compressionOptions = compressionLevel != null
? Map.of(CompressActionFactory.COMPRESSION_LEVEL, compressionLevel)
: Map.of();
return new DefaultRolloverStrategy(
minIndex,
maxIndex,
useMax,
Map.of(CompressActionFactory.COMPRESSION_LEVEL, compressionLevel),
compressionOptions,
nonNullStrSubstitutor,
customActions,
stopCustomActionsOnError,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ public DirectWriteRolloverStrategy build() {
maxIndex = DEFAULT_MAX_FILES;
}
}
final Map<String, ?> compressionOptions = compressionLevel != null
? Map.of(CompressActionFactory.COMPRESSION_LEVEL, compressionLevel)
: Map.of();
return new DirectWriteRolloverStrategy(
maxIndex,
Map.of(CompressActionFactory.COMPRESSION_LEVEL, compressionLevel),
compressionOptions,
config.getStrSubstitutor(),
customActions,
stopCustomActionsOnError,
Expand Down

0 comments on commit 3d35565

Please sign in to comment.