Skip to content

Commit

Permalink
Simplify logger creation leveraging Map.computeIfAbsent
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Apr 13, 2023
1 parent 432bd7a commit b7a3d85
Showing 1 changed file with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,7 @@ public Optional<LogLevelRecorder> getLogLevelRecorder() {
*/
@Override
public Logger getLogger(String name) {
Logger simpleLogger = loggerMap.get(name);
if (simpleLogger != null) {
return simpleLogger;
} else {
Logger newInstance = getNewLoggingInstance(name);
Logger oldInstance = loggerMap.putIfAbsent(name, newInstance);
return oldInstance == null ? newInstance : oldInstance;
}
return loggerMap.computeIfAbsent(name, this::getNewLoggingInstance);
}

private Logger getNewLoggingInstance(String name) {
Expand Down

0 comments on commit b7a3d85

Please sign in to comment.