@@ -75,7 +75,7 @@ public final class Logger
7575     * 'aai variable is set is within the addAppender method. This method is 
7676     * synchronized on 'this' (Logger) protecting against simultaneous 
7777     * re-configuration of this logger (a very unlikely scenario). 
78-      *   
78+      * 
7979     * <p> 
8080     * It is further assumed that the AppenderAttachableImpl is responsible for its 
8181     * internal synchronization and thread safety. Thus, we can get away with *not* 
@@ -132,19 +132,14 @@ private boolean isRootLogger() {
132132    Logger  getChildByName (final  String  childName ) {
133133        if  (childrenList  == null ) {
134134            return  null ;
135-         } else  {
136-             int  len  = this .childrenList .size ();
137-             for  (int  i  = 0 ; i  < len ; i ++) {
138-                 final  Logger  childLogger_i  = (Logger ) childrenList .get (i );
139-                 final  String  childName_i  = childLogger_i .getName ();
140- 
141-                 if  (childName .equals (childName_i )) {
142-                     return  childLogger_i ;
143-                 }
135+         }
136+         for  (final  Logger  child  : childrenList ) {
137+             if  (childName .equals (child .getName ())) {
138+                 return  child ;
144139            }
145-             // no child found 
146-             return  null ;
147140        }
141+         // no child found 
142+         return  null ;
148143    }
149144
150145    public  synchronized  void  setLevel (Level  newLevel ) {
@@ -165,11 +160,9 @@ public synchronized void setLevel(Level newLevel) {
165160        }
166161
167162        if  (childrenList  != null ) {
168-             int  len  = childrenList .size ();
169-             for  (int  i  = 0 ; i  < len ; i ++) {
170-                 Logger  child  = (Logger ) childrenList .get (i );
163+             for  (Logger  childLogger  : childrenList ) {
171164                // tell child to handle parent levelInt change 
172-                 child .handleParentLevelChange (effectiveLevelInt );
165+                 childLogger .handleParentLevelChange (effectiveLevelInt );
173166            }
174167        }
175168        // inform listeners 
@@ -179,7 +172,7 @@ public synchronized void setLevel(Level newLevel) {
179172    /** 
180173     * This method is invoked by parent logger to let this logger know that the 
181174     * prent's levelInt changed. 
182-      *   
175+      * 
183176     * @param newParentLevelInt 
184177     */ 
185178    private  synchronized  void  handleParentLevelChange (int  newParentLevelInt ) {
@@ -190,10 +183,8 @@ private synchronized void handleParentLevelChange(int newParentLevelInt) {
190183
191184            // propagate the parent levelInt change to this logger's children 
192185            if  (childrenList  != null ) {
193-                 int  len  = childrenList .size ();
194-                 for  (int  i  = 0 ; i  < len ; i ++) {
195-                     Logger  child  = (Logger ) childrenList .get (i );
196-                     child .handleParentLevelChange (newParentLevelInt );
186+                 for  (Logger  childLogger  : childrenList ) {
187+                     childLogger .handleParentLevelChange (newParentLevelInt );
197188                }
198189            }
199190        }
@@ -250,7 +241,7 @@ public Appender<ILoggingEvent> getAppender(String name) {
250241
251242    /** 
252243     * Invoke all the appenders of this logger. 
253-      *   
244+      * 
254245     * @param event The event to log 
255246     */ 
256247    public  void  callAppenders (ILoggingEvent  event ) {
@@ -289,11 +280,11 @@ public boolean detachAppender(Appender<ILoggingEvent> appender) {
289280     * Create a child of this logger by suffix, that is, the part of the name 
290281     * extending this logger. For example, if this logger is named "x.y" and the 
291282     * lastPart is "z", then the created child logger will be named "x.y.z". 
292-      *   
283+      * 
293284     * <p> 
294285     * IMPORTANT: Calls to this method must be within a synchronized block on this 
295286     * logger. 
296-      *   
287+      * 
297288     * @param lastPart the suffix (i.e. last part) of the child logger name. This 
298289     *                 parameter may not include dots, i.e. the logger separator 
299290     *                 character. 
@@ -341,23 +332,17 @@ void recursiveReset() {
341332        }
342333    }
343334
344-     /** 
345-      * The default size of child list arrays. The JDK 1.5 default is 10. We use a 
346-      * smaller value to save a little space. 
347-      */ 
348- 
349-     Logger  createChildByName (final  String  childName ) {
335+     synchronized  Logger  createChildByName (final  String  childName ) {
350336        int  i_index  = LoggerNameUtil .getSeparatorIndexOf (childName , this .name .length () + 1 );
351337        if  (i_index  != -1 ) {
352338            throw  new  IllegalArgumentException ("For logger ["  + this .name  + "] child name ["  + childName 
353339                    + " passed as parameter, may not include '.' after index"  + (this .name .length () + 1 ));
354340        }
355341
356342        if  (childrenList  == null ) {
357-             childrenList  = new  CopyOnWriteArrayList <Logger >();
343+             childrenList  = new  CopyOnWriteArrayList <>();
358344        }
359-         Logger  childLogger ;
360-         childLogger  = new  Logger (childName , this , this .loggerContext );
345+         final  Logger  childLogger  = new  Logger (childName , this , this .loggerContext );
361346        childrenList .add (childLogger );
362347        childLogger .effectiveLevelInt  = this .effectiveLevelInt ;
363348        return  childLogger ;
@@ -744,11 +729,11 @@ public String toString() {
744729    /** 
745730     * Method that calls the attached TurboFilter objects based on the logger and 
746731     * the level. 
747-      *   
732+      * 
748733     * It is used by isYYYEnabled() methods. 
749-      *   
734+      * 
750735     * It returns the typical FilterReply values: ACCEPT, NEUTRAL or DENY. 
751-      *   
736+      * 
752737     * @param level 
753738     * @return the reply given by the TurboFilters 
754739     */ 
@@ -758,7 +743,7 @@ private FilterReply callTurboFilters(Marker marker, Level level) {
758743
759744    /** 
760745     * Return the context for this logger. 
761-      *   
746+      * 
762747     * @return the context 
763748     */ 
764749    public  LoggerContext  getLoggerContext () {
@@ -767,7 +752,7 @@ public LoggerContext getLoggerContext() {
767752
768753    /** 
769754     * Creates a {@link LoggingEventBuilder} of type {@link DefaultLoggingEventBuilder}. 
770-      *   
755+      * 
771756     * @since 1.3 
772757     */ 
773758    @ Override 
@@ -783,7 +768,7 @@ public void log(Marker marker, String fqcn, int levelInt, String message, Object
783768    /** 
784769     * Support SLF4J interception during initialization as introduced in SLF4J 
785770     * version 1.7.15 
786-      *   
771+      * 
787772     * @since 1.1.4 
788773     * @param slf4jEvent 
789774     */ 
@@ -821,7 +806,7 @@ public void log(org.slf4j.event.LoggingEvent slf4jEvent) {
821806     * After serialization, the logger instance does not know its LoggerContext. The 
822807     * best we can do here, is to return a logger with the same name returned by 
823808     * org.slf4j.LoggerFactory. 
824-      *   
809+      * 
825810     * @return Logger instance with the same name 
826811     * @throws ObjectStreamException 
827812     */ 
0 commit comments