-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix FileRenameAction when the source file doesn't exist #3021
Fix FileRenameAction when the source file doesn't exist #3021
Conversation
[@king-tyler, I am leaving this to @ppkarwasz, since he was the one who took care of #2952. Piotr will be back in a day or two.] |
Hi @king-tyler and thank you for your contribution. The IMHO the main purpose of the action is to leave space for a new log file and the action should not destroy data, so the logic could be:
The current code goes on with some other techniques like "copy/delete".
|
The current implementation uses StandardCopyOptions.REPLACE_EXISTING: FileRenameAction.java#L209. It doesn't fail if the destination exists, and it does overwrite the the destination if it exists. I think this (along with your point 4) should be tracked in a separate issue and separate pull request. The problem in #2592 is that if FileNameAction returns false (i.e., fails) during a rollover, then the appender stops logging to any file. Perhaps the issue should be resolved differently than this PR? Maybe the RollingFileManager essentially aborts the rollover and continues logging to the existing file if FileNameAction fails. |
Yes, I believe that the manager should reopen the log file regardless of the result of the Lines 507 to 514 in f90dee8
Lines 617 to 646 in f90dee8
The problem described in #2592 is on line 639, where the wrong variable is returned. There are two pairs of actions that must be executed one after another:
|
Do you plan some changes in this PR or should I close it in favor of #3226? |
This one can be closed |
Fixes #2592
Fixes FileRenameAction when the source file doesn't exist.
Checklist
2.x
branch if you are targeting Log4j 2; usemain
otherwise./mvnw verify
succeeds (if it fails due to code formatting issues reported by Spotless, simply run./mvnw spotless:apply
and retry)src/changelog/.2.x.x
directory