http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java index 3c733d4..335018e 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DefaultRolloverStrategy.java @@ -90,10 +90,10 @@ public class DefaultRolloverStrategy extends AbstractRolloverStrategy { public static class Builder implements org.apache.logging.log4j.core.util.Builder<DefaultRolloverStrategy> { @PluginBuilderAttribute("max") private String max; - + @PluginBuilderAttribute("min") private String min; - + @PluginBuilderAttribute("fileIndex") private String fileIndex; @@ -143,7 +143,7 @@ public class DefaultRolloverStrategy extends AbstractRolloverStrategy { } final int compressionLevel = Integers.parseInt(compressionLevelStr, Deflater.DEFAULT_COMPRESSION); // The config object can be null when this object is built programmatically. - StrSubstitutor nonNullStrSubstitutor = config != null ? config.getStrSubstitutor() : new StrSubstitutor(); + final StrSubstitutor nonNullStrSubstitutor = config != null ? config.getStrSubstitutor() : new StrSubstitutor(); return new DefaultRolloverStrategy(minIndex, maxIndex, useMax, compressionLevel, nonNullStrSubstitutor, customActions, stopCustomActionsOnError, tempCompressedFilePattern); } @@ -260,7 +260,7 @@ public class DefaultRolloverStrategy extends AbstractRolloverStrategy { /** * Defines configuration. - * + * * @param config The Configuration. * @return This builder for chaining convenience */
http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java index b1ee506..8c6d259 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/DirectWriteRolloverStrategy.java @@ -60,7 +60,7 @@ import org.apache.logging.log4j.core.util.Integers; public class DirectWriteRolloverStrategy extends AbstractRolloverStrategy implements DirectFileRolloverStrategy { private static final int DEFAULT_MAX_FILES = 7; - + /** * Builds DirectWriteRolloverStrategy instances. */ @@ -181,7 +181,7 @@ public class DirectWriteRolloverStrategy extends AbstractRolloverStrategy implem /** * Defines configuration. - * + * * @param config The Configuration. * @return This builder for chaining convenience */ @@ -349,7 +349,7 @@ public class DirectWriteRolloverStrategy extends AbstractRolloverStrategy implem nextIndex = fileIndex + 1; final FileExtension fileExtension = manager.getFileExtension(); if (fileExtension != null) { - compressedName += fileExtension.getExtension(); + compressedName += fileExtension.getExtension(); if (tempCompressedFilePattern != null) { final StringBuilder buf = new StringBuilder(); tempCompressedFilePattern.formatFileName(strSubstitutor, buf, fileIndex); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java index 9d0016f..b859d79 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/FileExtension.java @@ -121,5 +121,5 @@ public enum FileExtension { File target(final String fileName) { return new File(fileName); - } + } } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/NoOpTriggeringPolicy.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/NoOpTriggeringPolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/NoOpTriggeringPolicy.java index b9af0a0..ff554e7 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/NoOpTriggeringPolicy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/NoOpTriggeringPolicy.java @@ -24,7 +24,7 @@ import org.apache.logging.log4j.core.config.plugins.PluginFactory; /* * Never triggers and is handy for edge-cases in tests for example. - * + * * @since 2.11.1 */ @Plugin(name = "NoOpTriggeringPolicy", category = Core.CATEGORY_NAME, printObject = true) http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java index affb809..a3fb930 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/RollingRandomAccessFileManager.java @@ -130,8 +130,8 @@ public class RollingRandomAccessFileManager extends RollingFileManager { protected synchronized void writeToDestination(final byte[] bytes, final int offset, final int length) { try { if (randomAccessFile == null) { - String fileName = getFileName(); - File file = new File(fileName); + final String fileName = getFileName(); + final File file = new File(fileName); FileUtils.makeParentDirs(file); createFileAfterRollover(fileName); } @@ -148,7 +148,7 @@ public class RollingRandomAccessFileManager extends RollingFileManager { createFileAfterRollover(getFileName()); } - private void createFileAfterRollover(String fileName) throws IOException { + private void createFileAfterRollover(final String fileName) throws IOException { this.randomAccessFile = new RandomAccessFile(fileName, "rw"); if (isAppend()) { randomAccessFile.seek(randomAccessFile.length()); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java index 7f6ac79..3cadd42 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TimeBasedTriggeringPolicy.java @@ -33,18 +33,18 @@ import org.apache.logging.log4j.core.util.Integers; @Plugin(name = "TimeBasedTriggeringPolicy", category = Core.CATEGORY_NAME, printObject = true) public final class TimeBasedTriggeringPolicy extends AbstractTriggeringPolicy { - + public static class Builder implements org.apache.logging.log4j.core.util.Builder<TimeBasedTriggeringPolicy> { @PluginBuilderAttribute private int interval = 1; - + @PluginBuilderAttribute private boolean modulate = false; - + @PluginBuilderAttribute private int maxRandomDelay = 0; - + @Override public TimeBasedTriggeringPolicy build() { final long maxRandomDelayMillis = TimeUnit.SECONDS.toMillis(maxRandomDelay); @@ -62,17 +62,17 @@ public final class TimeBasedTriggeringPolicy extends AbstractTriggeringPolicy { public int getMaxRandomDelay() { return maxRandomDelay; } - + public Builder withInterval(final int interval){ this.interval = interval; return this; } - + public Builder withModulate(final boolean modulate){ this.modulate = modulate; return this; } - + public Builder withMaxRandomDelay(final int maxRandomDelay){ this.maxRandomDelay = maxRandomDelay; return this; @@ -108,10 +108,10 @@ public final class TimeBasedTriggeringPolicy extends AbstractTriggeringPolicy { @Override public void initialize(final RollingFileManager aManager) { this.manager = aManager; - + // LOG4J2-531: call getNextTime twice to force initialization of both prevFileTime and nextFileTime aManager.getPatternProcessor().getNextTime(aManager.getFileTime(), interval, modulate); - + nextRolloverMillis = ThreadLocalRandom.current().nextLong(0, 1 + maxRandomDelayMillis) + aManager.getPatternProcessor().getNextTime(aManager.getFileTime(), interval, modulate); } @@ -151,7 +151,7 @@ public final class TimeBasedTriggeringPolicy extends AbstractTriggeringPolicy { .withModulate(Boolean.parseBoolean(modulate)) .build(); } - + @PluginBuilderFactory public static TimeBasedTriggeringPolicy.Builder newBuilder() { return new Builder(); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java index ed6a3f1..bb68d90 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/TriggeringPolicy.java @@ -22,7 +22,7 @@ import org.apache.logging.log4j.core.LogEvent; * A <code>TriggeringPolicy</code> controls the conditions under which rollover * occurs. Such conditions include time of day, file size, an * external event, the log request or a combination thereof. - * + * * @see AbstractTriggeringPolicy */ public interface TriggeringPolicy /* TODO 3.0: extends LifeCycle */ { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractAction.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractAction.java index 633d4bc..f6a92ff 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractAction.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractAction.java @@ -26,7 +26,7 @@ import org.apache.logging.log4j.status.StatusLogger; * Abstract base class for implementations of Action. */ public abstract class AbstractAction implements Action { - + /** * Allows subclasses access to the status logger without creating another instance. */ http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractPathAction.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractPathAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractPathAction.java index f8ddf48..7d8ac06 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractPathAction.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/AbstractPathAction.java @@ -45,7 +45,7 @@ public abstract class AbstractPathAction extends AbstractAction { /** * Creates a new AbstractPathAction that starts scanning for files to process from the specified base path. - * + * * @param basePath base path from where to start scanning for files to process. * @param followSymbolicLinks whether to follow symbolic links. Default is false. * @param maxDepth The maxDepth parameter is the maximum number of levels of directories to visit. A value of 0 @@ -57,7 +57,7 @@ public abstract class AbstractPathAction extends AbstractAction { protected AbstractPathAction(final String basePath, final boolean followSymbolicLinks, final int maxDepth, final PathCondition[] pathFilters, final StrSubstitutor subst) { this.basePathString = basePath; - this.options = followSymbolicLinks ? EnumSet.of(FileVisitOption.FOLLOW_LINKS) + this.options = followSymbolicLinks ? EnumSet.of(FileVisitOption.FOLLOW_LINKS) : Collections.<FileVisitOption> emptySet(); this.maxDepth = maxDepth; this.pathConditions = Arrays.asList(Arrays.copyOf(pathFilters, pathFilters.length)); @@ -87,7 +87,7 @@ public abstract class AbstractPathAction extends AbstractAction { * method when the {@link #execute()} method is invoked. * <p> * The visitor is responsible for processing the files it encounters that are accepted by all filters. - * + * * @param visitorBaseDir base dir from where to start scanning for files to process * @param conditions filters that determine if a file should be processed * @return a new {@code FileVisitor<Path>} @@ -99,7 +99,7 @@ public abstract class AbstractPathAction extends AbstractAction { * Returns the base path from where to start scanning for files to delete. Lookups are resolved, so if the * configuration was <code><Delete basePath="${sys:user.home}/abc" /></code> then this method returns a path * to the "abc" file or directory in the user's home directory. - * + * * @return the base path (all lookups resolved) */ public Path getBasePath() { @@ -108,7 +108,7 @@ public abstract class AbstractPathAction extends AbstractAction { /** * Returns the base path as it was specified in the configuration. Lookups are not resolved. - * + * * @return the base path as it was specified in the configuration */ public String getBasePathString() { @@ -121,16 +121,16 @@ public abstract class AbstractPathAction extends AbstractAction { /** * Returns whether to follow symbolic links or not. - * + * * @return the options */ public Set<FileVisitOption> getOptions() { return Collections.unmodifiableSet(options); } - + /** * Returns whether to follow symbolic links or not. - * + * * @return whether to follow symbolic links or not */ public boolean isFollowSymbolicLinks() { @@ -139,7 +139,7 @@ public abstract class AbstractPathAction extends AbstractAction { /** * Returns the the maximum number of directory levels to visit. - * + * * @return the maxDepth */ public int getMaxDepth() { @@ -148,7 +148,7 @@ public abstract class AbstractPathAction extends AbstractAction { /** * Returns the list of PathCondition objects. - * + * * @return the pathFilters */ public List<PathCondition> getPathConditions() { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CommonsCompressAction.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CommonsCompressAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CommonsCompressAction.java index 6d0c6e2..e461a8c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CommonsCompressAction.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CommonsCompressAction.java @@ -140,7 +140,7 @@ public final class CommonsCompressAction extends AbstractAction { @Override public String toString() { - return CommonsCompressAction.class.getSimpleName() + '[' + source + " to " + destination + return CommonsCompressAction.class.getSimpleName() + '[' + source + " to " + destination + ", deleteSource=" + deleteSource + ']'; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CompositeAction.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CompositeAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CompositeAction.java index 5637144..8d5a48b 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CompositeAction.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/CompositeAction.java @@ -25,7 +25,7 @@ import java.util.List; * A group of Actions to be executed in sequence. */ public class CompositeAction extends AbstractAction { - + /** * Actions to perform. */ @@ -99,7 +99,7 @@ public class CompositeAction extends AbstractAction { return status; } - + @Override public String toString() { return CompositeAction.class.getSimpleName() + Arrays.toString(actions); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java index 76e9b00..a0fbac6 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeleteAction.java @@ -45,7 +45,7 @@ public class DeleteAction extends AbstractPathAction { /** * Creates a new DeleteAction that starts scanning for files to delete from the specified base path. - * + * * @param basePath base path from where to start scanning for files to delete. * @param followSymbolicLinks whether to follow symbolic links. Default is false. * @param maxDepth The maxDepth parameter is the maximum number of levels of directories to visit. A value of 0 @@ -74,7 +74,7 @@ public class DeleteAction extends AbstractPathAction { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.AbstractPathAction#execute() */ @Override @@ -113,7 +113,7 @@ public class DeleteAction extends AbstractPathAction { /** * Deletes the specified file. - * + * * @param path the file to delete * @throws IOException if a problem occurred deleting the file */ @@ -124,7 +124,7 @@ public class DeleteAction extends AbstractPathAction { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.AbstractPathAction#execute(FileVisitor) */ @Override @@ -153,7 +153,7 @@ public class DeleteAction extends AbstractPathAction { /** * Returns a sorted list of all files up to maxDepth under the basePath. - * + * * @return a sorted list of files * @throws IOException */ @@ -166,7 +166,7 @@ public class DeleteAction extends AbstractPathAction { /** * Returns {@code true} if files are not deleted even when all conditions accept a path, {@code false} otherwise. - * + * * @return {@code true} if files are not deleted even when all conditions accept a path, {@code false} otherwise */ public boolean isTestMode() { @@ -180,7 +180,7 @@ public class DeleteAction extends AbstractPathAction { /** * Create a DeleteAction. - * + * * @param basePath base path from where to start scanning for files to delete. * @param followLinks whether to follow symbolic links. Default is false. * @param maxDepth The maxDepth parameter is the maximum number of levels of directories to visit. A value of 0 @@ -199,7 +199,7 @@ public class DeleteAction extends AbstractPathAction { @PluginFactory public static DeleteAction createDeleteAction( // @formatter:off - @PluginAttribute("basePath") final String basePath, + @PluginAttribute("basePath") final String basePath, @PluginAttribute(value = "followLinks") final boolean followLinks, @PluginAttribute(value = "maxDepth", defaultInt = 1) final int maxDepth, @PluginAttribute(value = "testMode") final boolean testMode, http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitor.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitor.java index 825e774..45ddd33 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitor.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/DeletingVisitor.java @@ -1,97 +1,97 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache license, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the license for the specific language governing permissions and - * limitations under the license. - */ - -package org.apache.logging.log4j.core.appender.rolling.action; - -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.List; -import java.util.Objects; - -import org.apache.logging.log4j.Logger; -import org.apache.logging.log4j.status.StatusLogger; - -/** - * FileVisitor that deletes files that are accepted by all PathFilters. Directories are ignored. - */ -public class DeletingVisitor extends SimpleFileVisitor<Path> { - private static final Logger LOGGER = StatusLogger.getLogger(); - - private final Path basePath; - private final boolean testMode; - private final List<? extends PathCondition> pathConditions; - - /** - * Constructs a new DeletingVisitor. - * - * @param basePath used to relativize paths - * @param pathConditions objects that need to confirm whether a file can be deleted - * @param testMode if true, files are not deleted but instead a message is printed to the <a - * href="http://logging.apache.org/log4j/2.x/manual/configuration.html#StatusMessages">status logger</a> - * at INFO level. Users can use this to do a dry run to test if their configuration works as expected. - */ - public DeletingVisitor(final Path basePath, final List<? extends PathCondition> pathConditions, - final boolean testMode) { - this.testMode = testMode; - this.basePath = Objects.requireNonNull(basePath, "basePath"); - this.pathConditions = Objects.requireNonNull(pathConditions, "pathConditions"); - for (final PathCondition condition : pathConditions) { - condition.beforeFileTreeWalk(); - } - } - - @Override - public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { - for (final PathCondition pathFilter : pathConditions) { - final Path relative = basePath.relativize(file); - if (!pathFilter.accept(basePath, relative, attrs)) { - LOGGER.trace("Not deleting base={}, relative={}", basePath, relative); - return FileVisitResult.CONTINUE; - } - } - if (isTestMode()) { - LOGGER.info("Deleting {} (TEST MODE: file not actually deleted)", file); - } else { - delete(file); - } - return FileVisitResult.CONTINUE; - } - - /** - * Deletes the specified file. - * - * @param file the file to delete - * @throws IOException if a problem occurred deleting the file - */ - protected void delete(final Path file) throws IOException { - LOGGER.trace("Deleting {}", file); - Files.deleteIfExists(file); - } - - /** - * Returns {@code true} if files are not deleted even when all conditions accept a path, {@code false} otherwise. - * - * @return {@code true} if files are not deleted even when all conditions accept a path, {@code false} otherwise - */ - public boolean isTestMode() { - return testMode; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ + +package org.apache.logging.log4j.core.appender.rolling.action; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.List; +import java.util.Objects; + +import org.apache.logging.log4j.Logger; +import org.apache.logging.log4j.status.StatusLogger; + +/** + * FileVisitor that deletes files that are accepted by all PathFilters. Directories are ignored. + */ +public class DeletingVisitor extends SimpleFileVisitor<Path> { + private static final Logger LOGGER = StatusLogger.getLogger(); + + private final Path basePath; + private final boolean testMode; + private final List<? extends PathCondition> pathConditions; + + /** + * Constructs a new DeletingVisitor. + * + * @param basePath used to relativize paths + * @param pathConditions objects that need to confirm whether a file can be deleted + * @param testMode if true, files are not deleted but instead a message is printed to the <a + * href="http://logging.apache.org/log4j/2.x/manual/configuration.html#StatusMessages">status logger</a> + * at INFO level. Users can use this to do a dry run to test if their configuration works as expected. + */ + public DeletingVisitor(final Path basePath, final List<? extends PathCondition> pathConditions, + final boolean testMode) { + this.testMode = testMode; + this.basePath = Objects.requireNonNull(basePath, "basePath"); + this.pathConditions = Objects.requireNonNull(pathConditions, "pathConditions"); + for (final PathCondition condition : pathConditions) { + condition.beforeFileTreeWalk(); + } + } + + @Override + public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) throws IOException { + for (final PathCondition pathFilter : pathConditions) { + final Path relative = basePath.relativize(file); + if (!pathFilter.accept(basePath, relative, attrs)) { + LOGGER.trace("Not deleting base={}, relative={}", basePath, relative); + return FileVisitResult.CONTINUE; + } + } + if (isTestMode()) { + LOGGER.info("Deleting {} (TEST MODE: file not actually deleted)", file); + } else { + delete(file); + } + return FileVisitResult.CONTINUE; + } + + /** + * Deletes the specified file. + * + * @param file the file to delete + * @throws IOException if a problem occurred deleting the file + */ + protected void delete(final Path file) throws IOException { + LOGGER.trace("Deleting {}", file); + Files.deleteIfExists(file); + } + + /** + * Returns {@code true} if files are not deleted even when all conditions accept a path, {@code false} otherwise. + * + * @return {@code true} if files are not deleted even when all conditions accept a path, {@code false} otherwise + */ + public boolean isTestMode() { + return testMode; + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java index 5305c91..8684a29 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/Duration.java @@ -29,7 +29,7 @@ import java.util.regex.Pattern; * <p> * Similarly to the {@code java.time.Duration} class, this class does not support year or month sections in the format. * This implementation does not support fractions or negative values. - * + * * @see #parse(CharSequence) */ public class Duration implements Serializable, Comparable<Duration> { @@ -101,7 +101,7 @@ public class Duration implements Serializable, Comparable<Duration> { * positive symbol. The number of days, hours, minutes and seconds must parse to a {@code long}. * <p> * Examples: - * + * * <pre> * "PT20S" -- parses as "20 seconds" * "PT15M" -- parses as "15 minutes" (where a minute is 60 seconds) @@ -205,14 +205,14 @@ public class Duration implements Serializable, Comparable<Duration> { * all positive. * <p> * Examples: - * + * * <pre> * "20 seconds" -- "PT20S * "15 minutes" (15 * 60 seconds) -- "PT15M" * "10 hours" (10 * 3600 seconds) -- "PT10H" * "2 days" (2 * 86400 seconds) -- "P2D" * </pre> - * + * * @return an ISO-8601 representation of this duration, not null */ @Override @@ -247,7 +247,7 @@ public class Duration implements Serializable, Comparable<Duration> { /* * (non-Javadoc) - * + * * @see java.lang.Comparable#compareTo(java.lang.Object) */ @Override http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/GzCompressAction.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/GzCompressAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/GzCompressAction.java index 1c9b082..eb8e6e3 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/GzCompressAction.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/GzCompressAction.java @@ -121,7 +121,7 @@ public final class GzCompressAction extends AbstractAction { @Override public String toString() { - return GzCompressAction.class.getSimpleName() + '[' + source + " to " + destination + return GzCompressAction.class.getSimpleName() + '[' + source + " to " + destination + ", deleteSource=" + deleteSource + ']'; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java index b47954f..f5761bb 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileCount.java @@ -59,7 +59,7 @@ public final class IfAccumulatedFileCount implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path, * java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes) */ @@ -78,7 +78,7 @@ public final class IfAccumulatedFileCount implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk() */ @Override @@ -89,12 +89,12 @@ public final class IfAccumulatedFileCount implements PathCondition { /** * Create an IfAccumulatedFileCount condition. - * + * * @param threshold The threshold count from which files will be deleted. * @return An IfAccumulatedFileCount condition. */ @PluginFactory - public static IfAccumulatedFileCount createFileCountCondition( + public static IfAccumulatedFileCount createFileCountCondition( // @formatter:off @PluginAttribute(value = "exceeds", defaultInt = Integer.MAX_VALUE) final int threshold, @PluginElement("PathConditions") final PathCondition... nestedConditions) { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java index 7c1d908..6cc6ab6 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAccumulatedFileSize.java @@ -60,7 +60,7 @@ public final class IfAccumulatedFileSize implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path, * java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes) */ @@ -80,7 +80,7 @@ public final class IfAccumulatedFileSize implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk() */ @Override @@ -91,12 +91,12 @@ public final class IfAccumulatedFileSize implements PathCondition { /** * Create an IfAccumulatedFileSize condition. - * + * * @param threshold The threshold accumulated file size from which files will be deleted. * @return An IfAccumulatedFileSize condition. */ @PluginFactory - public static IfAccumulatedFileSize createFileSizeCondition( + public static IfAccumulatedFileSize createFileSizeCondition( // @formatter:off @PluginAttribute("exceeds") final String size, @PluginElement("PathConditions") final PathCondition... nestedConditions) { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java index 2eaea8b..27596cb 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAll.java @@ -45,7 +45,7 @@ public final class IfAll implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path, * java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes) */ @@ -59,7 +59,7 @@ public final class IfAll implements PathCondition { /** * Returns {@code true} if all the specified conditions accept the specified path, {@code false} otherwise. - * + * * @param list the array of conditions to evaluate * @param baseDir the directory from where to start scanning for deletion candidate files * @param relativePath the candidate for deletion. This path is relative to the baseDir. @@ -79,7 +79,7 @@ public final class IfAll implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk() */ @Override @@ -89,7 +89,7 @@ public final class IfAll implements PathCondition { /** * Calls {@link #beforeFileTreeWalk()} on all of the specified nested conditions. - * + * * @param nestedConditions the conditions to call {@link #beforeFileTreeWalk()} on */ public static void beforeFileTreeWalk(final PathCondition[] nestedConditions) { @@ -100,12 +100,12 @@ public final class IfAll implements PathCondition { /** * Create a Composite PathCondition whose components all need to accept before this condition accepts. - * + * * @param components The component filters. * @return A Composite PathCondition. */ @PluginFactory - public static IfAll createAndCondition( + public static IfAll createAndCondition( @PluginElement("PathConditions") final PathCondition... components) { return new IfAll(components); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java index 6d5841f..a982b58 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfAny.java @@ -70,12 +70,12 @@ public final class IfAny implements PathCondition { /** * Create a Composite PathCondition: accepts if any of the nested conditions accepts. - * + * * @param components The component conditions. * @return A Composite PathCondition. */ @PluginFactory - public static IfAny createOrCondition( + public static IfAny createOrCondition( @PluginElement("PathConditions") final PathCondition... components) { return new IfAny(components); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java index 1084a77..34ee066 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfFileName.java @@ -52,7 +52,7 @@ public final class IfFileName implements PathCondition { /** * Constructs a FileNameFilter filter. If both a regular expression and a glob pattern are specified the glob * pattern is used and the regular expression is ignored. - * + * * @param glob the baseDir-relative path pattern of the files to delete (may contain '*' and '?' wildcarts) * @param regex the regular expression that matches the baseDir-relative path of the file(s) to delete * @param nestedConditions nested conditions to evaluate if this condition accepts a path @@ -80,7 +80,7 @@ public final class IfFileName implements PathCondition { * {@code syntax:pattern} where syntax is one of "glob" or "regex" and the pattern is either a {@linkplain Pattern * regular expression} or a simplified pattern expression described under "glob" in * {@link FileSystem#getPathMatcher(String)}. - * + * * @return relative path of the file(s) to delete (may contain regular expression or wildcarts) */ public String getSyntaxAndPattern() { @@ -93,7 +93,7 @@ public final class IfFileName implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path, * java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes) */ @@ -112,7 +112,7 @@ public final class IfFileName implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk() */ @Override @@ -125,7 +125,7 @@ public final class IfFileName implements PathCondition { * {@linkplain FileSystem#getPathMatcher(String) glob pattern} or the regular expression matches the relative path. * If both a regular expression and a glob pattern are specified the glob pattern is used and the regular expression * is ignored. - * + * * @param glob the baseDir-relative path pattern of the files to delete (may contain '*' and '?' wildcarts) * @param regex the regular expression that matches the baseDir-relative path of the file(s) to delete * @param nestedConditions nested conditions to evaluate if this condition accepts a path @@ -133,10 +133,10 @@ public final class IfFileName implements PathCondition { * @see FileSystem#getPathMatcher(String) */ @PluginFactory - public static IfFileName createNameCondition( + public static IfFileName createNameCondition( // @formatter:off - @PluginAttribute("glob") final String glob, - @PluginAttribute("regex") final String regex, + @PluginAttribute("glob") final String glob, + @PluginAttribute("regex") final String regex, @PluginElement("PathConditions") final PathCondition... nestedConditions) { // @formatter:on return new IfFileName(glob, regex, nestedConditions); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java index 4a4c717..eff6536 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfLastModified.java @@ -61,7 +61,7 @@ public final class IfLastModified implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#accept(java.nio.file.Path, * java.nio.file.Path, java.nio.file.attribute.BasicFileAttributes) */ @@ -82,7 +82,7 @@ public final class IfLastModified implements PathCondition { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.appender.rolling.action.PathCondition#beforeFileTreeWalk() */ @Override @@ -92,15 +92,15 @@ public final class IfLastModified implements PathCondition { /** * Create an IfLastModified condition. - * + * * @param age The path age that is accepted by this condition. Must be a valid Duration. * @param nestedConditions nested conditions to evaluate if this condition accepts a path * @return An IfLastModified condition. */ @PluginFactory - public static IfLastModified createAgeCondition( + public static IfLastModified createAgeCondition( // @formatter:off - @PluginAttribute("age") final Duration age, + @PluginAttribute("age") final Duration age, @PluginElement("PathConditions") final PathCondition... nestedConditions) { // @formatter:on return new IfLastModified(age, nestedConditions); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfNot.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfNot.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfNot.java index 1baf187..998a713 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfNot.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/IfNot.java @@ -61,12 +61,12 @@ public final class IfNot implements PathCondition { /** * Create an IfNot PathCondition. - * + * * @param condition The condition to negate. * @return An IfNot PathCondition. */ @PluginFactory - public static IfNot createNotCondition( + public static IfNot createNotCondition( @PluginElement("PathConditions") final PathCondition condition) { return new IfNot(condition); } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathCondition.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathCondition.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathCondition.java index 0fa7873..8b8944c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathCondition.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathCondition.java @@ -1,44 +1,44 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache license, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the license for the specific language governing permissions and - * limitations under the license. - */ - -package org.apache.logging.log4j.core.appender.rolling.action; - -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.attribute.BasicFileAttributes; - -/** - * Filter that accepts or rejects a candidate {@code Path} for deletion. - */ -public interface PathCondition { - - /** - * Invoked before a new {@linkplain Files#walkFileTree(Path, java.util.Set, int, java.nio.file.FileVisitor) file - * tree walk} is started. Stateful PathConditions can reset their state when this method is called. - */ - void beforeFileTreeWalk(); - - /** - * Returns {@code true} if the specified candidate path should be deleted, {@code false} otherwise. - * - * @param baseDir the directory from where to start scanning for deletion candidate files - * @param relativePath the candidate for deletion. This path is relative to the baseDir. - * @param attrs attributes of the candidate path - * @return whether the candidate path should be deleted - */ - boolean accept(final Path baseDir, final Path relativePath, final BasicFileAttributes attrs); -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ + +package org.apache.logging.log4j.core.appender.rolling.action; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; + +/** + * Filter that accepts or rejects a candidate {@code Path} for deletion. + */ +public interface PathCondition { + + /** + * Invoked before a new {@linkplain Files#walkFileTree(Path, java.util.Set, int, java.nio.file.FileVisitor) file + * tree walk} is started. Stateful PathConditions can reset their state when this method is called. + */ + void beforeFileTreeWalk(); + + /** + * Returns {@code true} if the specified candidate path should be deleted, {@code false} otherwise. + * + * @param baseDir the directory from where to start scanning for deletion candidate files + * @param relativePath the candidate for deletion. This path is relative to the baseDir. + * @param attrs attributes of the candidate path + * @return whether the candidate path should be deleted + */ + boolean accept(final Path baseDir, final Path relativePath, final BasicFileAttributes attrs); +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTime.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTime.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTime.java index e0a04b5..468dee7 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTime.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathSortByModificationTime.java @@ -37,7 +37,7 @@ public class PathSortByModificationTime implements PathSorter, Serializable { /** * Constructs a new SortByModificationTime sorter. - * + * * @param recentFirst if true, most recently modified paths should come first */ public PathSortByModificationTime(final boolean recentFirst) { @@ -47,19 +47,19 @@ public class PathSortByModificationTime implements PathSorter, Serializable { /** * Create a PathSorter that sorts by lastModified time. - * + * * @param recentFirst if true, most recently modified paths should come first. * @return A PathSorter. */ @PluginFactory - public static PathSorter createSorter( + public static PathSorter createSorter( @PluginAttribute(value = "recentFirst", defaultBoolean = true) final boolean recentFirst) { return new PathSortByModificationTime(recentFirst); } /** * Returns whether this sorter sorts recent files first. - * + * * @return whether this sorter sorts recent files first */ public boolean isRecentFirst() { @@ -68,7 +68,7 @@ public class PathSortByModificationTime implements PathSorter, Serializable { /* * (non-Javadoc) - * + * * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ @Override http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathWithAttributes.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathWithAttributes.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathWithAttributes.java index 42640c3..7dbc92c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathWithAttributes.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PathWithAttributes.java @@ -1,59 +1,59 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache license, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the license for the specific language governing permissions and - * limitations under the license. - */ - -package org.apache.logging.log4j.core.appender.rolling.action; - -import java.nio.file.Path; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.Objects; - -/** - * Tuple of a {@code Path} and {@code BasicFileAttributes}, used for sorting. - */ -public class PathWithAttributes { - - private final Path path; - private final BasicFileAttributes attributes; - - public PathWithAttributes(final Path path, final BasicFileAttributes attributes) { - this.path = Objects.requireNonNull(path, "path"); - this.attributes = Objects.requireNonNull(attributes, "attributes"); - } - - @Override - public String toString() { - return path + " (modified: " + attributes.lastModifiedTime() + ")"; - } - - /** - * Returns the path. - * - * @return the path - */ - public Path getPath() { - return path; - } - - /** - * Returns the attributes. - * - * @return the attributes - */ - public BasicFileAttributes getAttributes() { - return attributes; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ + +package org.apache.logging.log4j.core.appender.rolling.action; + +import java.nio.file.Path; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.Objects; + +/** + * Tuple of a {@code Path} and {@code BasicFileAttributes}, used for sorting. + */ +public class PathWithAttributes { + + private final Path path; + private final BasicFileAttributes attributes; + + public PathWithAttributes(final Path path, final BasicFileAttributes attributes) { + this.path = Objects.requireNonNull(path, "path"); + this.attributes = Objects.requireNonNull(attributes, "attributes"); + } + + @Override + public String toString() { + return path + " (modified: " + attributes.lastModifiedTime() + ")"; + } + + /** + * Returns the path. + * + * @return the path + */ + public Path getPath() { + return path; + } + + /** + * Returns the attributes. + * + * @return the attributes + */ + public BasicFileAttributes getAttributes() { + return attributes; + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PosixViewAttributeAction.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PosixViewAttributeAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PosixViewAttributeAction.java index bb5bc74..0cf6ba5 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PosixViewAttributeAction.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/PosixViewAttributeAction.java @@ -43,12 +43,12 @@ import org.apache.logging.log4j.util.Strings; /** * File posix attribute view action. - * + * * Allow to define file permissions, user and group for log files on posix supported OS. */ @Plugin(name = "PosixViewAttribute", category = Core.CATEGORY_NAME, printObject = true) public class PosixViewAttributeAction extends AbstractPathAction { - + /** * File permissions. */ @@ -86,7 +86,7 @@ public class PosixViewAttributeAction extends AbstractPathAction { @PluginConfiguration private Configuration configuration; - + private StrSubstitutor subst; @PluginBuilderAttribute @@ -183,7 +183,7 @@ public class PosixViewAttributeAction extends AbstractPathAction { /** * Define max folder depth to search for eligible files to apply posix attribute view. - * @param maxDepth Max search depth + * @param maxDepth Max search depth * @return This builder */ public Builder withMaxDepth(final int maxDepth) { @@ -275,10 +275,10 @@ public class PosixViewAttributeAction extends AbstractPathAction { public Set<PosixFilePermission> getFilePermissions() { return filePermissions; } - + /** * Returns file owner if defined and the OS supports owner file attribute view, - * null otherwise. + * null otherwise. * @return File owner * @see FileOwnerAttributeView */ @@ -288,7 +288,7 @@ public class PosixViewAttributeAction extends AbstractPathAction { /** * Returns file group if defined and the OS supports posix/group file attribute view, - * null otherwise. + * null otherwise. * @return File group * @see PosixFileAttributeView */ http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptCondition.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptCondition.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptCondition.java index 9d728c0..6ef46ed 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptCondition.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ScriptCondition.java @@ -38,7 +38,7 @@ import org.apache.logging.log4j.status.StatusLogger; /** * A condition of the {@link DeleteAction} where a user-provided script selects the files to delete from a provided * list. The specified script may be a {@link Script}, a {@link ScriptFile} or a {@link ScriptRef}. - * + * * @see #createCondition(AbstractScript, Configuration) */ @Plugin(name = "ScriptCondition", category = Core.CATEGORY_NAME, printObject = true) @@ -50,7 +50,7 @@ public class ScriptCondition { /** * Constructs a new ScriptCondition. - * + * * @param script the script that can select files to delete * @param configuration configuration containing the StrSubstitutor passed to the script */ @@ -64,7 +64,7 @@ public class ScriptCondition { /** * Executes the script - * + * * @param baseDir * @param candidates * @return @@ -84,7 +84,7 @@ public class ScriptCondition { /** * Creates the ScriptCondition. - * + * * @param script The script to run. This may be a {@link Script}, a {@link ScriptFile} or a {@link ScriptRef}. The * script must return a {@code List<PathWithAttributes>}. When the script is executed, it is provided the * following bindings: http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitor.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitor.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitor.java index 7bf76b6..7b6d956 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitor.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/SortingVisitor.java @@ -1,58 +1,58 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache license, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the license for the specific language governing permissions and - * limitations under the license. - */ - -package org.apache.logging.log4j.core.appender.rolling.action; - -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Objects; - -/** - * FileVisitor that sorts files. - */ -public class SortingVisitor extends SimpleFileVisitor<Path> { - - private final PathSorter sorter; - private final List<PathWithAttributes> collected = new ArrayList<>(); - - /** - * Constructs a new DeletingVisitor. - * - * @param basePath used to relativize paths - * @param pathFilters objects that need to confirm whether a file can be deleted - */ - public SortingVisitor(final PathSorter sorter) { - this.sorter = Objects.requireNonNull(sorter, "sorter"); - } - - @Override - public FileVisitResult visitFile(final Path path, final BasicFileAttributes attrs) throws IOException { - collected.add(new PathWithAttributes(path, attrs)); - return FileVisitResult.CONTINUE; - } - - public List<PathWithAttributes> getSortedPaths() { - Collections.sort(collected, sorter); - return collected; - } -} +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache license, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the license for the specific language governing permissions and + * limitations under the license. + */ + +package org.apache.logging.log4j.core.appender.rolling.action; + +import java.io.IOException; +import java.nio.file.FileVisitResult; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + * FileVisitor that sorts files. + */ +public class SortingVisitor extends SimpleFileVisitor<Path> { + + private final PathSorter sorter; + private final List<PathWithAttributes> collected = new ArrayList<>(); + + /** + * Constructs a new DeletingVisitor. + * + * @param basePath used to relativize paths + * @param pathFilters objects that need to confirm whether a file can be deleted + */ + public SortingVisitor(final PathSorter sorter) { + this.sorter = Objects.requireNonNull(sorter, "sorter"); + } + + @Override + public FileVisitResult visitFile(final Path path, final BasicFileAttributes attrs) throws IOException { + collected.add(new PathWithAttributes(path, attrs)); + return FileVisitResult.CONTINUE; + } + + public List<PathWithAttributes> getSortedPaths() { + Collections.sort(collected, sorter); + return collected; + } +} http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ZipCompressAction.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ZipCompressAction.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ZipCompressAction.java index a7705da..3a0019f 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ZipCompressAction.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/ZipCompressAction.java @@ -132,7 +132,7 @@ public final class ZipCompressAction extends AbstractAction { @Override public String toString() { - return ZipCompressAction.class.getSimpleName() + '[' + source + " to " + destination + return ZipCompressAction.class.getSimpleName() + '[' + source + " to " + destination + ", level=" + level + ", deleteSource=" + deleteSource + ']'; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java index e892f66..1babc38 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/IdlePurgePolicy.java @@ -41,7 +41,7 @@ import org.apache.logging.log4j.core.config.plugins.PluginFactory; public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, Runnable { private final long timeToLive; - private final long checkInterval; + private final long checkInterval; private final ConcurrentMap<String, Long> appendersUsage = new ConcurrentHashMap<>(); private RoutingAppender routingAppender; private final ConfigurationScheduler scheduler; @@ -123,7 +123,7 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R * Create the PurgePolicy * * @param timeToLive the number of increments of timeUnit before the Appender should be purged. - * @param checkInterval when all appenders purged, the number of increments of timeUnit to check if any appenders appeared + * @param checkInterval when all appenders purged, the number of increments of timeUnit to check if any appenders appeared * @param timeUnit the unit of time the timeToLive and the checkInterval is expressed in. * @return The Routes container. */ @@ -155,7 +155,7 @@ public class IdlePurgePolicy extends AbstractLifeCycle implements PurgePolicy, R LOGGER.error("timeToLive must be positive. timeToLive set to 0"); ttl = 0; } - + long ci; if (checkInterval == null) { ci = ttl; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/PurgePolicy.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/PurgePolicy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/PurgePolicy.java index b0c8c61..f780b15 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/PurgePolicy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/PurgePolicy.java @@ -27,9 +27,9 @@ public interface PurgePolicy { * Activates purging appenders */ void purge(); - + /** - * + * * @param routed appender key * @param event */ @@ -37,7 +37,7 @@ public interface PurgePolicy { /** * Initializes with routing appender - * + * * @param routingAppender */ void initialize(RoutingAppender routingAppender); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java index e179ad7..f02b7cf 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/appender/routing/Routes.java @@ -47,12 +47,12 @@ public final class Routes { public static class Builder implements org.apache.logging.log4j.core.util.Builder<Routes> { - @PluginConfiguration + @PluginConfiguration private Configuration configuration; - @PluginAttribute("pattern") + @PluginAttribute("pattern") private String pattern; - + @PluginElement("Script") private AbstractScript patternScript; @@ -114,7 +114,7 @@ public final class Routes { this.routes = routes; return this; } - + } private static final Logger LOGGER = StatusLogger.getLogger(); @@ -141,16 +141,16 @@ public final class Routes { public static Builder newBuilder() { return new Builder(); } - + private final Configuration configuration; - + private final String pattern; private final AbstractScript patternScript; - + // TODO Why not make this a Map or add a Map. private final Route[] routes; - + private Routes(final Configuration configuration, final AbstractScript patternScript, final String pattern, final Route... routes) { this.configuration = configuration; this.patternScript = patternScript; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java index 06d219a..61ca41f 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerConfig.java @@ -86,6 +86,7 @@ public class AsyncLoggerConfig extends LoggerConfig { delegate.setLogEventFactory(getLogEventFactory()); } + @Override protected void log(final LogEvent event, final LoggerConfigPredicate predicate) { // See LOG4J2-2301 if (predicate == LoggerConfigPredicate.ALL && @@ -120,7 +121,7 @@ public class AsyncLoggerConfig extends LoggerConfig { super.callAppenders(event); } - private void logToAsyncDelegate(LogEvent event) { + private void logToAsyncDelegate(final LogEvent event) { if (!isFiltered(event)) { // Passes on the event to a separate thread that will call // asyncCallAppenders(LogEvent). http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java index 68326f7..fa93851 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContext.java @@ -58,7 +58,7 @@ public class AsyncLoggerContext extends LoggerContext { protected Logger newInstance(final LoggerContext ctx, final String name, final MessageFactory messageFactory) { return new AsyncLogger(ctx, name, messageFactory, loggerDisruptor); } - + @Override public void setName(final String name) { super.setName("AsyncContext[" + name + "]"); @@ -67,7 +67,7 @@ public class AsyncLoggerContext extends LoggerContext { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.LoggerContext#start() */ @Override @@ -78,7 +78,7 @@ public class AsyncLoggerContext extends LoggerContext { /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.LoggerContext#start(org.apache.logging.log4j.core.config.Configuration) */ @Override @@ -102,7 +102,7 @@ public class AsyncLoggerContext extends LoggerContext { public boolean stop(final long timeout, final TimeUnit timeUnit) { setStopping(); // first stop Disruptor - loggerDisruptor.stop(timeout, timeUnit); + loggerDisruptor.stop(timeout, timeUnit); super.stop(timeout, timeUnit); return true; } http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java index 358b265..b8fe437 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/AsyncLoggerContextSelector.java @@ -33,7 +33,7 @@ public class AsyncLoggerContextSelector extends ClassLoaderContextSelector { /** * Returns {@code true} if the user specified this selector as the Log4jContextSelector, to make all loggers * asynchronous. - * + * * @return {@code true} if all loggers are asynchronous, {@code false} otherwise. */ public static boolean isSelected() { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java index 8af33e7..c259fc2 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/async/RingBufferLogEvent.java @@ -69,7 +69,7 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen private int threadPriority; private long threadId; - private MutableInstant instant = new MutableInstant(); + private final MutableInstant instant = new MutableInstant(); private long nanoTime; private short parameterCount; private boolean includeLocation; @@ -281,7 +281,7 @@ public class RingBufferLogEvent implements LogEvent, ReusableMessage, CharSequen } @Override - public <S> void forEachParameter(ParameterConsumer<S> action, S state) { + public <S> void forEachParameter(final ParameterConsumer<S> action, final S state) { if (parameters != null) { for (short i = 0; i < parameterCount; i++) { action.accept(parameters[i], i, state); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java index 1e4a820..8194ffc 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java @@ -40,7 +40,7 @@ public class AppenderControl extends AbstractFilterable { /** * Constructor. - * + * * @param appender The target Appender. * @param level the Level to filter on. * @param filter the Filter(s) to apply. @@ -56,7 +56,7 @@ public class AppenderControl extends AbstractFilterable { /** * Returns the name the appender had when this AppenderControl was constructed. - * + * * @return the appender name */ public String getAppenderName() { @@ -65,7 +65,7 @@ public class AppenderControl extends AbstractFilterable { /** * Returns the Appender. - * + * * @return the Appender. */ public Appender getAppender() { @@ -74,7 +74,7 @@ public class AppenderControl extends AbstractFilterable { /** * Call the appender. - * + * * @param event The event to process. */ public void callAppender(final LogEvent event) { http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java index 357f18b..bd582b5 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AwaitUnconditionallyReliabilityStrategy.java @@ -47,7 +47,7 @@ public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrat /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier, * java.lang.String, java.lang.String, org.apache.logging.log4j.Marker, org.apache.logging.log4j.Level, * org.apache.logging.log4j.message.Message, java.lang.Throwable) @@ -60,7 +60,7 @@ public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrat /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#log(org.apache.logging.log4j.util.Supplier, * org.apache.logging.log4j.core.LogEvent) */ @@ -71,7 +71,7 @@ public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrat /* * (non-Javadoc) - * + * * @see * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeLogEvent(org.apache.logging.log4j.core.config. * LoggerConfig, org.apache.logging.log4j.util.Supplier) @@ -83,7 +83,7 @@ public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrat /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#afterLogEvent() */ @Override @@ -93,7 +93,7 @@ public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrat /* * (non-Javadoc) - * + * * @see org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopAppenders() */ @Override @@ -103,7 +103,7 @@ public class AwaitUnconditionallyReliabilityStrategy implements ReliabilityStrat /* * (non-Javadoc) - * + * * @see * org.apache.logging.log4j.core.config.ReliabilityStrategy#beforeStopConfiguration(org.apache.logging.log4j.core * .config.Configuration) http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java index 5341337..dd7525c 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationScheduler.java @@ -38,7 +38,7 @@ public class ConfigurationScheduler extends AbstractLifeCycle { private static final Logger LOGGER = StatusLogger.getLogger(); private static final String SIMPLE_NAME = "Log4j2 " + ConfigurationScheduler.class.getSimpleName(); private static final int MAX_SCHEDULED_ITEMS = 5; - + private ScheduledExecutorService executorService; private int scheduledItems = 0; private final String name; http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java index 3c87695..21558fc 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/ConfigurationSource.java @@ -275,7 +275,7 @@ public class ConfigurationSource { if (is == null) { return null; } - + if (FileUtils.isFile(url)) { try { return new ConfigurationSource(is, FileUtils.fileFromUri(url.toURI())); http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/a8a7e7c9/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java ---------------------------------------------------------------------- diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java index 28dd85f..0747399 100644 --- a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java +++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/Configurator.java @@ -335,7 +335,7 @@ public final class Configurator { * rollover thread is done. When this method returns, these tasks' status are undefined, the tasks may be done or * not. * </p> - * + * * @param ctx * the logger context to shut down, may be null. */