Drop TypeConfigurationRegistry which was leaking session factories that had a bootstrap error
As far as I can tell, the purpose of TypeConfigurationRegistry was only for serialization, but since the TypeConfiguration UUID is always random, this won't work anyway.
This commit is contained in:
parent
ffe45ccdd6
commit
709ac039d1
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
|
||||
*/
|
||||
package org.hibernate.type.internal;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* A Registry of TypeConfiguration references based on the
|
||||
* TypeConfiguration's UUID.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TypeConfigurationRegistry {
|
||||
private static final Logger LOG = Logger.getLogger( TypeConfigurationRegistry.class );
|
||||
|
||||
/**
|
||||
* Singleton access
|
||||
*/
|
||||
public static final TypeConfigurationRegistry INSTANCE = new TypeConfigurationRegistry();
|
||||
|
||||
private TypeConfigurationRegistry() {
|
||||
}
|
||||
|
||||
private ConcurrentHashMap<String,TypeConfiguration> configurationMap;
|
||||
|
||||
public void registerTypeConfiguration(TypeConfiguration typeConfiguration) {
|
||||
if ( configurationMap == null ) {
|
||||
configurationMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
configurationMap.put( typeConfiguration.getUuid(), typeConfiguration );
|
||||
}
|
||||
|
||||
public TypeConfiguration findTypeConfiguration(String uuid) {
|
||||
if ( configurationMap == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return configurationMap.get( uuid );
|
||||
}
|
||||
|
||||
public void deregisterTypeConfiguration(TypeConfiguration typeConfiguration) {
|
||||
final TypeConfiguration existing = configurationMap.remove( typeConfiguration.getUuid() );
|
||||
if ( existing != typeConfiguration ) {
|
||||
LOG.debugf(
|
||||
"Different TypeConfiguration [%s] passed to #deregisterTypeConfiguration than previously registered [%s] under that UUID [%s]",
|
||||
typeConfiguration,
|
||||
existing,
|
||||
typeConfiguration.getUuid()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -37,7 +37,6 @@ import org.hibernate.type.TypeFactory;
|
|||
import org.hibernate.type.TypeResolver;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeDescriptorRegistry;
|
||||
import org.hibernate.type.descriptor.sql.spi.SqlTypeDescriptorRegistry;
|
||||
import org.hibernate.type.internal.TypeConfigurationRegistry;
|
||||
|
||||
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||
|
||||
|
@ -88,8 +87,6 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
|
|||
this.basicTypeRegistry = new BasicTypeRegistry();
|
||||
this.typeFactory = new TypeFactory( this );
|
||||
this.typeResolver = new TypeResolver( this, typeFactory );
|
||||
|
||||
TypeConfigurationRegistry.INSTANCE.registerTypeConfiguration( this );
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
|
@ -210,8 +207,6 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
|
|||
public void sessionFactoryClosed(SessionFactory factory) {
|
||||
log.tracef( "Handling #sessionFactoryClosed from [%s] for TypeConfiguration", factory );
|
||||
|
||||
TypeConfigurationRegistry.INSTANCE.deregisterTypeConfiguration( this );
|
||||
|
||||
scope.unsetSessionFactory( factory );
|
||||
|
||||
// todo (6.0) : finish this
|
||||
|
@ -374,12 +369,4 @@ public class TypeConfiguration implements SessionFactoryObserver, Serializable {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Custom serialization hook
|
||||
|
||||
private Object readResolve() throws InvalidObjectException {
|
||||
log.trace( "Resolving serialized TypeConfiguration - readResolve" );
|
||||
return TypeConfigurationRegistry.INSTANCE.findTypeConfiguration( getUuid() );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue