[logback-dev] [JIRA] Commented: (LBCLASSIC-54) TurboFilterAttachableImpl.addTurboFilter() will behave funny if newFilter.turboNext != null

Ceki Gulcu (JIRA) noreply-jira at qos.ch
Fri Oct 31 13:02:21 CET 2008


    [ http://jira.qos.ch/browse/LBCLASSIC-54?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=10870#action_10870 ] 

Ceki Gulcu commented on LBCLASSIC-54:
-------------------------------------

The most general solution would be to add methods such as add(int index, TurboFilter tf) and remove(int index, TurboFilter tf) which would make TurboFitlerAttacable more similar to the java.util.List interface. 

Performance of iterating over the chain was the reason why opted for arranging filters (and turbo filters) in a linked chain. This was in JDK 1.1 or 1.2. In JDK 1.5, my tests show that the iterating over the chain is not faster with our custom implementation than with a vanilla ArrayList. Actually, for the most important case, where there are no turbo filters (empty chain), the vanilla list is about 12% faster! We go from 9.5 nanoseconds per iteration to 8.4 nanoseconds. Imagine my surprise. 

I thus intend to refactor the code and migrate to a more standard solution.

> TurboFilterAttachableImpl.addTurboFilter() will behave funny if newFilter.turboNext != null
> -------------------------------------------------------------------------------------------
>
>                 Key: LBCLASSIC-54
>                 URL: http://jira.qos.ch/browse/LBCLASSIC-54
>             Project: logback-classic
>          Issue Type: Bug
>            Reporter: Anton Tagunov
>            Assignee: Logback dev list
>            Priority: Minor
>
> Hi!
> addTurboFilter() sets tailFilter incorrectly if newFilter.nextFilter != null
> Here's what I was trying to do.
> I implement a new TurboFilter.
> This TurboFilter is an interceptor that captures log messages and stores them for analysis.
> This is part of Unit Test. This Unit Test has to ensure that a specific message has been logged.
> This TurboFilter is not configured via logback.xml
> It can be but I don't want that to be mandatory.
> Instead this TurboFilter needs to bind itself to LoggerContext programmatically, via Logback API.
> It also need to bind itself as _the first filter in the chain_.
> Here's how I've tried to do it:
>       final LogbackMessageProducer nuvo = new LogbackMessageProducer(true);
>       
>       /* make sure we're the first in the chain */
>       final TurboFilter oldFirst = tfa.getFirstTurboFilter();
>       nuvo.setNext(oldFirst);
>       
>       tfa.clearAllTurboFilters();
>       tfa.addTurboFilter(nuvo);
> However should somebody else call addTurboFilter(some-other-filter) after this behavior shall be funny.
> Basically all old turbo filters that were bound before my code executed shall be lost.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        


More information about the logback-dev mailing list