1
0

Use Map API

This commit is contained in:
Gary Gregory
2023-11-19 16:30:24 -05:00
parent f8aeeaec61
commit 704258ca41

View File

@@ -254,7 +254,7 @@ public class LogFactoryImpl extends LogFactory {
* The {@link org.apache.commons.logging.Log} instances that have * The {@link org.apache.commons.logging.Log} instances that have
* already been created, keyed by logger name. * already been created, keyed by logger name.
*/ */
protected Hashtable instances = new Hashtable(); protected Hashtable<String, Log> instances = new Hashtable<>();
/** /**
* Name of the class implementing the Log interface. * Name of the class implementing the Log interface.
@@ -846,12 +846,7 @@ public class LogFactoryImpl extends LogFactory {
*/ */
@Override @Override
public Log getInstance(final String name) throws LogConfigurationException { public Log getInstance(final String name) throws LogConfigurationException {
Log instance = (Log) instances.get(name); return instances.computeIfAbsent(name, this::newInstance);
if (instance == null) {
instance = newInstance(name);
instances.put(name, instance);
}
return instance;
} }
/** /**