You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Pawandeep Singh Bhatti (Jira)" <ji...@apache.org> on 2022/08/10 10:59:00 UTC
[jira] [Commented] (LOG4J2-3569) Incorrect logic/code or comment for AbstractFilterable.isFiltered method
[ https://issues.apache.org/jira/browse/LOG4J2-3569?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17577923#comment-17577923 ]
Pawandeep Singh Bhatti commented on LOG4J2-3569:
------------------------------------------------
I see contradictory implementations at multiple places in code:
1.
org.apache.logging.log4j.core.config.AppenderControl#isFilteredByAppenderControl
private boolean isFilteredByAppenderControl(final LogEvent event) {
final Filter filter = getFilter();
return filter != null && Filter.Result.DENY == filter.filter(event);
}
2.
org.apache.logging.log4j.core.appender.SmtpAppender#isFiltered
/**
* Capture all events in CyclicBuffer.
* @param event The Log event.
* @return true if the event should be filtered.
*/
@Override
public boolean isFiltered(final LogEvent event) {
final boolean filtered = super.isFiltered(event);
if (filtered) {
// SHOULD we add it to Cyclic Buffer if it is supposed to be filtered out ?
manager.add(event);
}
return filtered;
}
> Incorrect logic/code or comment for AbstractFilterable.isFiltered method
> -------------------------------------------------------------------------
>
> Key: LOG4J2-3569
> URL: https://issues.apache.org/jira/browse/LOG4J2-3569
> Project: Log4j 2
> Issue Type: Bug
> Components: Filters
> Affects Versions: 2.17.2
> Environment: All Enviroments
> Reporter: Pawandeep Singh Bhatti
> Priority: Blocker
>
> Hello,
>
> This is my first issue ever for an open source project.
>
> I was going through Log4j2 source code and stumbled upon following method:
> {code:java}
> /**
> * Determine if the LogEvent should be processed or ignored.
> * @param event The LogEvent.
> * @return true if the LogEvent should be processed.
> */
> @Override
> public boolean isFiltered(final LogEvent event) {
> return filter != null && filter.filter(event) == Filter.Result.DENY;
> } {code}
>
>
> Here is a link to the code on github:
> [Link|https://github.com/apache/logging-log4j2/blob/40214e87c46c9534abcd8c5abf2b154f4c561002/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/AbstractFilterable.java#L153]
> Either the java doc is incorrect - which says @return true if the LogEvent should be processed.
> Or this line is wrong,
> return filter != null && filter.filter(event) == Filter.Result.DENY;
>
> Please check.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)