Skip to content

Commit

Permalink
Merge pull request #225 from madisparn/master
Browse files Browse the repository at this point in the history
Fix NullPointerException when Logger is removed while looping
  • Loading branch information
tntim96 committed Mar 30, 2016
2 parents 5a3b21b + b8d19bf commit 89ffb42
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/main/java/jscover/util/LoggerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,9 @@ private void alterLoggers(Level level, File file) throws IOException {
while (names.hasMoreElements()) {
String loggerName = names.nextElement();
Logger logger = LogManager.getLogManager().getLogger(loggerName);
if (logger == null) {
continue;
}
logger.setLevel(level);
logger.addHandler(fileTxt);
Handler[] handlers = logger.getHandlers();
Expand All @@ -401,6 +404,9 @@ private void addExceptionRecorder() {
while (names.hasMoreElements()) {
String loggerName = names.nextElement();
Logger logger = LogManager.getLogManager().getLogger(loggerName);
if (logger == null) {
continue;
}
logger.addHandler(exceptionRecordingHandler);
}
}
Expand Down

0 comments on commit 89ffb42

Please sign in to comment.