Skip to content
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

PAYARA-2822 Access logs are not being purged #2824

Merged
merged 5 commits into from
Jun 15, 2018

Conversation

MeroRai
Copy link
Member

@MeroRai MeroRai commented Jun 7, 2018

No description provided.

@MeroRai MeroRai added this to the Payara 5.183 milestone Jun 7, 2018
@MeroRai MeroRai self-assigned this Jun 7, 2018
* If undefined or value is less than 0, all history log are preserved.
*/
private void cleanUpHistoryLogFiles() {
if (maxHistoryFiles == 0 || maxHistoryFiles < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be written as <=

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@svendiedrichsen thanks for the review.


File[] allFilesInDirectory = fileDirectory.listFiles();
ArrayList<String> candidateListOfLogFiles = new ArrayList<>();

Copy link
Contributor

@svendiedrichsen svendiedrichsen Jun 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use List<File>? You could spare some File-Instance creation later on.

&& allFilesInDirectory[i].isFile()
&& allFilesInDirectory[i].getName().startsWith(prefix)) {
candidateListOfLogFiles.add(allFilesInDirectory[i].getAbsolutePath());
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you could then keep the File instance.


Object[] pathes = candidateListOfLogFiles.toArray();
Arrays.sort(pathes);
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you probably rather should use candidateListOfLogFiles.sort(<Comparator>) and provide a comparator which compares files by their absolute path.

Arrays.sort(pathes);
try {
for (int i = 0; i < pathes.length - maxHistoryFiles; i++) {
File logFile = new File((String) pathes[i]);
Copy link
Contributor

@svendiedrichsen svendiedrichsen Jun 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't needed anymore if you stayed with File and you could use a simpler for-loop syntax.

File logFile = new File((String) pathes[i]);
boolean delFile = logFile.delete();
if (!delFile) {
throw new IOException("Could not delete Access log file: "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems harsh to do. Wouldn't it be better to write a log message here and continue removing log files. Otherwise a single undeletable log will stop log file removal forever.

Copy link
Contributor

@MarkWareham MarkWareham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend changing the _logger to LOGGER and _resourceBundle to RESOURCE_BUNDLE

@MeroRai
Copy link
Member Author

MeroRai commented Jun 13, 2018

jenkins test

@payara-ci
Copy link
Contributor

Quick build and test passed!

@Pandrex247 Pandrex247 merged commit 7310b0f into payara:master Jun 15, 2018
MeroRai pushed a commit to MeroRai/Payara that referenced this pull request Jun 18, 2018
PAYARA-2822 Access logs are not beeing purged
@MeroRai MeroRai changed the title PAYARA-2822 Access logs are not beeing purged PAYARA-2822 Access logs are not being purged Aug 31, 2018
@payara-ci
Copy link
Contributor

Quick build and test passed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants