Oh, on another note, it would be ever so slightly more efficient to invert
the tests. You are always testing both matches && LOG.isTraceEnabled() in
the current implementation, but there's no need to check matches if trace
isn't enabled. So, maybe something like:
/**
* Checks if name of Cookie match {@link #acceptedPattern}
*
* @param name of Cookie
* @return true|false
*/
protected boolean isAccepted(String name){
boolean matches = acceptedPattern.matcher(name).matches();
if(LOG.isTraceEnabled()) {
if(matches) {
LOG.trace("Cookie [#0] matches acceptedPattern
[#1]",name,acceptedPattern.pattern());
} else {
LOG.trace("Cookie [#0] doesn't match acceptedPattern
[#1]",name,acceptedPattern.pattern());
}
}
return matches;
}
On Tue Dec 16 2014 at 1:28:38 PM Chris Pratt <[email protected]>
wrote:
> Sorry, I don't have an environment set up to create a patch, but I found
> an error in the isAccepted() method. It currently looks like:
>
> /**
> * Checks if name of Cookie match {@link #acceptedPattern}
> *
> * @param name of Cookie
> * @return true|false
> */
> protected boolean isAccepted(String name) {
> boolean matches = acceptedPattern.matcher(name).matches();
> if (matches) {
> if (LOG.isTraceEnabled()) {
> LOG.trace("Cookie [#0] matches acceptedPattern [#1]", name,
> ACCEPTED_PATTERN);
> }
> } else {
> if (LOG.isTraceEnabled()) {
> LOG.trace("Cookie [#0] doesn't match acceptedPattern [#1]", name,
> ACCEPTED_PATTERN);
> }
> }
> return matches;
> }
>
>
> But it would be more useful if it actually reported the RegEx being used
> instead of the default. So something more like:
>
> /**
> * Checks if name of Cookie match {@link #acceptedPattern}
> *
> * @param name of Cookie
> * @return true|false
> */
> protected boolean isAccepted (String name) {
> boolean matches = acceptedPattern.matcher(name).matches();
> if(matches) {
> if(LOG.isTraceEnabled()) {
> LOG.trace("Cookie [#0] matches acceptedPattern
> [#1]",name,acceptedPattern.pattern());
> }
> } else {
> if(LOG.isTraceEnabled()) {
> LOG.trace("Cookie [#0] doesn't match acceptedPattern
> [#1]",name,acceptedPattern.pattern());
> }
> }
> return matches;
> }
>
> (*Chris*)
>