11/**
22 * Logback: the reliable, generic, fast and flexible logging framework.
33 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
4- *
4+ * <p>
55 * This program and the accompanying materials are dual-licensed under
66 * either the terms of the Eclipse Public License v1.0 as published by
77 * the Eclipse Foundation
8- *
9- * or (per the licensee's choosing)
10- *
8+ * <p>
9+ * or (per the licensee's choosing)
10+ * <p>
1111 * under the terms of the GNU Lesser General Public License version 2.1
1212 * as published by the Free Software Foundation.
1313 */
2424
2525/**
2626 * Implementation of TurboFilterAttachable.
27- *
27+ *
2828 * @author Ceki Gülcü
2929 */
3030final public class TurboFilterList extends CopyOnWriteArrayList <TurboFilter > {
@@ -37,31 +37,32 @@ final public class TurboFilterList extends CopyOnWriteArrayList<TurboFilter> {
3737 * then NEUTRAL is returned.
3838 */
3939 public FilterReply getTurboFilterChainDecision (final Marker marker , final Logger logger , final Level level ,
40- final String format , final Object [] params , final Throwable t ) {
40+ final String format , final Object [] params , final Throwable t ) {
4141
4242 final int size = size ();
43- // if (size == 0) {
44- // return FilterReply.NEUTRAL;
45- // }
43+ // caller may have already performed this check, but we do it here as well to be sure
44+ if (size == 0 ) {
45+ return FilterReply .NEUTRAL ;
46+ }
47+
4648 if (size == 1 ) {
4749 try {
4850 TurboFilter tf = get (0 );
4951 return tf .decide (marker , logger , level , format , params , t );
5052 } catch (IndexOutOfBoundsException iobe ) {
53+ // concurrent modification detected, fall through to the general case
5154 return FilterReply .NEUTRAL ;
5255 }
5356 }
5457
55- Object [] tfa = toArray ();
56- final int len = tfa .length ;
57- for (int i = 0 ; i < len ; i ++) {
58- // for (TurboFilter tf : this) {
59- final TurboFilter tf = (TurboFilter ) tfa [i ];
58+
59+ for (TurboFilter tf : this ) {
6060 final FilterReply r = tf .decide (marker , logger , level , format , params , t );
6161 if (r == FilterReply .DENY || r == FilterReply .ACCEPT ) {
6262 return r ;
6363 }
6464 }
65+
6566 return FilterReply .NEUTRAL ;
6667 }
6768
0 commit comments