WW-5184 Uses debug log level when parameter value was not accepted

This commit is contained in:
Lukasz Lenart
2022-09-28 11:09:16 +02:00
parent 326de812ac
commit ddbd02e6bb
@@ -272,7 +272,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
ParameterNameAware parameterNameAware = (action instanceof ParameterNameAware) ? (ParameterNameAware) action : null;
return acceptableName(name) && (parameterNameAware == null || parameterNameAware.acceptableParameterName(name));
}
/**
* Checks if parameter value can be accepted or thrown away
*
@@ -316,13 +316,13 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
return logEntry.toString();
}
/**
* Validates the name passed is:
* * Within the max length of a parameter name
* * Is not excluded
* * Is accepted
*
*
* @param name - Name to check
* @return true if accepted
*/
@@ -351,19 +351,24 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
* * Value is null/blank
* * Value is not excluded
* * Value is accepted
*
*
* @param name - Param name (for logging)
* @param value - value to check
* @return true if accepted
*/
protected boolean acceptableValue(String name, String value) {
boolean accepted = (value == null || value.isEmpty() || (!isParamValueExcluded(value) && isParamValueAccepted(value)));
boolean accepted = (value == null || value.isEmpty() || (!isParamValueExcluded(value) && isParamValueAccepted(value)));
if (!accepted) {
LOG.warn("Parameter [{}] was not accepted with value [{}] and will be dropped!", name, value);
String message = "Value [{}] of parameter [{}] was not accepted and will be dropped!";
if (devMode) {
LOG.warn(message, value, name);
} else {
LOG.debug(message, value, name);
}
}
return accepted;
}
protected boolean isWithinLengthLimit(String name) {
boolean matchLength = name.length() <= paramNameMaxLength;
if (!matchLength) {
@@ -407,7 +412,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
}
return false;
}
public void setAcceptedValuePatterns(String commaDelimitedPatterns) {
Set<String> patterns = TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns);
@@ -427,7 +432,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
acceptedValuePatterns = Collections.unmodifiableSet(acceptedValuePatterns);
}
}
public void setExcludeValuePatterns(String commaDelimitedPatterns) {
Set<String> patterns = TextParseUtil.commaDelimitedStringToSet(commaDelimitedPatterns);
if (excludedValuePatterns == null) {
@@ -446,7 +451,7 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
excludedValuePatterns = Collections.unmodifiableSet(excludedValuePatterns);
}
}
protected boolean isParamValueExcluded(String value) {
if (hasParamValuesToExclude()) {
for (Pattern excludedPattern : excludedValuePatterns) {
@@ -478,15 +483,15 @@ public class ParametersInterceptor extends MethodFilterInterceptor {
LOG.warn("Parameter value [{}] did not match any acceptedValuePattern pattern and will be dropped.", value);
return false;
}
private boolean hasParamValuesToExclude() {
return excludedValuePatterns != null && excludedValuePatterns.size() > 0;
}
private boolean hasParamValuesToAccept() {
return acceptedValuePatterns != null && acceptedValuePatterns.size() > 0;
}
/**
* Whether to order the parameters or not
*