Skip to content

Commit 68f3b5d

Browse files
committed
Remove Unused comment in LoggerContext
1 parent 8749edc commit 68f3b5d

File tree

2 files changed

+33
-52
lines changed

2 files changed

+33
-52
lines changed

logback-classic/src/main/java/ch/qos/logback/classic/Logger.java

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/

logback-classic/src/main/java/ch/qos/logback/classic/LoggerContext.java

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,7 @@
2323
import java.util.Map;
2424
import java.util.concurrent.ConcurrentHashMap;
2525
import java.util.concurrent.ScheduledFuture;
26-
import java.util.concurrent.locks.ReentrantLock;
2726

28-
import ch.qos.logback.classic.util.LogbackMDCAdapter;
29-
import ch.qos.logback.core.status.ErrorStatus;
30-
import ch.qos.logback.core.status.InfoStatus;
3127
import org.slf4j.ILoggerFactory;
3228
import org.slf4j.Marker;
3329

@@ -66,7 +62,7 @@ public class LoggerContext extends ContextBase implements ILoggerFactory, LifeCy
6662
final Logger root;
6763
private int size;
6864
private int noAppenderWarning = 0;
69-
final private List<LoggerContextListener> loggerContextListenerList = new ArrayList<LoggerContextListener>();
65+
final private List<LoggerContextListener> loggerContextListenerList = new ArrayList<>();
7066

7167
private Map<String, Logger> loggerCache;
7268

@@ -84,15 +80,15 @@ public class LoggerContext extends ContextBase implements ILoggerFactory, LifeCy
8480

8581
public LoggerContext() {
8682
super();
87-
this.loggerCache = new ConcurrentHashMap<String, Logger>();
83+
this.loggerCache = new ConcurrentHashMap<>();
8884

8985
this.loggerContextRemoteView = new LoggerContextVO(this);
9086
this.root = new Logger(Logger.ROOT_LOGGER_NAME, null, this);
9187
this.root.setLevel(Level.DEBUG);
9288
loggerCache.put(Logger.ROOT_LOGGER_NAME, root);
9389
initEvaluatorMap();
9490
size = 1;
95-
this.frameworkPackages = new ArrayList<String>();
91+
this.frameworkPackages = new ArrayList<>();
9692
// In 1.5.7, the stop() method assumes that at some point the context has been started
9793
// since earlier versions of logback did not mandate calling the start method
9894
// we need to call in the constructor
@@ -145,7 +141,7 @@ public Logger getLogger(final String name) {
145141

146142
// check if the desired logger exists, if it does, return it
147143
// without further ado.
148-
Logger childLogger = (Logger) loggerCache.get(name);
144+
Logger childLogger = loggerCache.get(name);
149145
// if we have the child, then let us return it without wasting time
150146
if (childLogger != null) {
151147
return childLogger;
@@ -193,7 +189,7 @@ int size() {
193189
* @param name the name of the logger to search for.
194190
*/
195191
public Logger exists(String name) {
196-
return (Logger) loggerCache.get(name);
192+
return loggerCache.get(name);
197193
}
198194

199195
final void noAppenderDefinedWarning(final Logger logger) {
@@ -204,7 +200,7 @@ final void noAppenderDefinedWarning(final Logger logger) {
204200

205201
public List<Logger> getLoggerList() {
206202
Collection<Logger> collection = loggerCache.values();
207-
List<Logger> loggerList = new ArrayList<Logger>(collection);
203+
List<Logger> loggerList = new ArrayList<>(collection);
208204
Collections.sort(loggerList, new LoggerComparator());
209205
return loggerList;
210206
}
@@ -297,7 +293,7 @@ public void removeListener(LoggerContextListener listener) {
297293
}
298294

299295
private void resetListenersExceptResetResistant() {
300-
List<LoggerContextListener> toRetain = new ArrayList<LoggerContextListener>();
296+
List<LoggerContextListener> toRetain = new ArrayList<>();
301297

302298
for (LoggerContextListener lcl : loggerContextListenerList) {
303299
if (lcl.isResetResistant()) {
@@ -312,7 +308,7 @@ private void resetAllListeners() {
312308
}
313309

314310
public List<LoggerContextListener> getCopyOfListenerList() {
315-
return new ArrayList<LoggerContextListener>(loggerContextListenerList);
311+
return new ArrayList<>(loggerContextListenerList);
316312
}
317313

318314
void fireOnLevelChange(Logger logger, Level level) {

0 commit comments

Comments
 (0)