Simplify logger creation leveraging Map.computeIfAbsent

This commit is contained in:
Guillaume Nodet 2023-04-06 15:52:12 +02:00
parent 432bd7af3a
commit b7a3d85713
1 changed files with 1 additions and 8 deletions

View File

@ -49,14 +49,7 @@ public class MavenLoggerFactory extends SimpleLoggerFactory implements MavenSlf4
*/
@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) {