Micro-tuning for StandardListenerFactory

This commit is contained in:
Sanne Grinovero 2013-08-01 23:28:44 +01:00
parent 8aff7db2e0
commit aea6b767ae
1 changed files with 6 additions and 3 deletions

View File

@ -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 @@ import org.hibernate.jpa.event.spi.jpa.ListenerFactory;
* @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 class StandardListenerFactory implements ListenerFactory {
e
);
}
listenerInstances.put( listenerClass, listenerInstance );
Object existing = listenerInstances.putIfAbsent( listenerClass, listenerInstance );
if ( existing != null ) {
listenerInstance = existing;
}
}
return (T) listenerInstance;
}