Github user garydgregory commented on a diff in the pull request:
https://github.com/apache/logging-log4j2/pull/107#discussion_r133317698
--- Diff:
log4j-core/src/main/java/org/apache/logging/log4j/core/appender/rolling/action/FileRenameAction.java
---
@@ -124,20 +124,22 @@ public static boolean execute(final File source,
final File destination, final b
} catch (final IOException exMove) {
LOGGER.error("Unable to move file {} to {}: {} {}",
source.getAbsolutePath(),
destination.getAbsolutePath(),
exMove.getClass().getName(), exMove.getMessage());
- final boolean result = source.renameTo(destination);
+ boolean result = source.renameTo(destination);
if (!result) {
try {
Files.copy(Paths.get(source.getAbsolutePath()),
Paths.get(destination.getAbsolutePath()),
StandardCopyOption.REPLACE_EXISTING);
try {
Files.delete(Paths.get(source.getAbsolutePath()));
+ result = true;
LOGGER.trace("Renamed file {} to {} using
copy and delete",
source.getAbsolutePath(),
destination.getAbsolutePath());
} catch (final IOException exDelete) {
LOGGER.error("Unable to delete file {}: {}
{}", source.getAbsolutePath(),
exDelete.getClass().getName(),
exDelete.getMessage());
try {
new
PrintWriter(source.getAbsolutePath()).close();
+ result = true;
--- End diff --
I would not set result to true here since the rename is incomplete at this
point, as the logging statement above says "Unable to delete file". The result
should be atomic IMO: true, the file was renamed. false: not done, or
incomplete.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---