mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-08 04:08:19 +00:00
Micro-tuning for StandardListenerFactory
This commit is contained in:
parent
8aff7db2e0
commit
aea6b767ae
@ -24,7 +24,6 @@
|
||||
package org.hibernate.jpa.event.internal.jpa;
|
||||
|
||||
import javax.persistence.PersistenceException;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.hibernate.jpa.event.spi.jpa.ListenerFactory;
|
||||
@ -36,7 +35,8 @@
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class StandardListenerFactory implements ListenerFactory {
|
||||
private Map listenerInstances = new ConcurrentHashMap();
|
||||
|
||||
private final ConcurrentHashMap listenerInstances = new ConcurrentHashMap();
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -52,7 +52,10 @@ public <T> T buildListener(Class<T> listenerClass) {
|
||||
e
|
||||
);
|
||||
}
|
||||
listenerInstances.put( listenerClass, listenerInstance );
|
||||
Object existing = listenerInstances.putIfAbsent( listenerClass, listenerInstance );
|
||||
if ( existing != null ) {
|
||||
listenerInstance = existing;
|
||||
}
|
||||
}
|
||||
return (T) listenerInstance;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user