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

Add validation to rotation interval in accesslog #43

Merged
merged 1 commit into from
Jun 3, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ public final class PEAccessLogValve
*/
private final static int MIN_BUFFER_SIZE = 5120;

/**
* The maximum size of a rotation interval value in minutes
*/
private static final int MAX_ROTATION_INTERVAL_IN_MINUTES = Integer.MAX_VALUE / 60;

// ----------------------------------------------------- Instance Variables

Expand Down Expand Up @@ -291,6 +295,15 @@ public void setRotationInterval(int t) {
rotationInterval = t;
}

/**
* Set rotation interval in minutes
*/
public void setRotationIntervalInMinutes(int t) {
if (t > MAX_ROTATION_INTERVAL_IN_MINUTES) {
throw new IllegalArgumentException("Invalid rotation-interval-in-minutes value [" + t + "]");
}
setRotationInterval(t * 60);
}

/**
* Set the direct <code>ByteBuffer</code> size
Expand Down Expand Up @@ -786,11 +799,11 @@ void updateAccessLogAttributes(HttpService httpService,
interval = 0;
if (accessLogConfig != null) {
String s = accessLogConfig.getRotationIntervalInMinutes();
interval = Integer.parseInt(s) * 60;
interval = Integer.parseInt(s);
} else {
interval = Integer.parseInt(ConfigBeansUtilities.getDefaultRotationIntervalInMinutes()) * 60;
interval = Integer.parseInt(ConfigBeansUtilities.getDefaultRotationIntervalInMinutes());
}
setRotationInterval(interval);
setRotationIntervalInMinutes(interval);

// rotation-datestamp
String rotationDateStamp = null;
Expand Down