From ab832caf0d773ab0f0b4e2f78741bf7ad4ba449b Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 10 Jul 2019 19:07:49 +0100 Subject: [PATCH] HHH-13495 Do not use BoundedConcurrentHashMap for NationalizedTypeMappings --- .../sql/NationalizedTypeMappings.java | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/NationalizedTypeMappings.java b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/NationalizedTypeMappings.java index eedea2e257..e3000bae8f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/NationalizedTypeMappings.java +++ b/hibernate-core/src/main/java/org/hibernate/type/descriptor/sql/NationalizedTypeMappings.java @@ -9,10 +9,6 @@ package org.hibernate.type.descriptor.sql; import java.sql.Types; import java.util.Map; -import org.hibernate.internal.util.collections.BoundedConcurrentHashMap; - -import org.jboss.logging.Logger; - /** * Manages a mapping between nationalized and non-nationalized variants of JDBC types. * @@ -22,33 +18,23 @@ import org.jboss.logging.Logger; * @author Steve Ebersole */ public class NationalizedTypeMappings { - private static final Logger log = Logger.getLogger( NationalizedTypeMappings.class ); /** * Singleton access */ public static final NationalizedTypeMappings INSTANCE = new NationalizedTypeMappings(); - private final Map nationalizedCodeByNonNationalized; - - public NationalizedTypeMappings() { - this.nationalizedCodeByNonNationalized = new BoundedConcurrentHashMap(); - map( Types.CHAR, Types.NCHAR ); - map( Types.CLOB, Types.NCLOB ); - map( Types.LONGVARCHAR, Types.LONGNVARCHAR ); - map( Types.VARCHAR, Types.NVARCHAR ); - } - - private void map(int nonNationalizedCode, int nationalizedCode) { - nationalizedCodeByNonNationalized.put( nonNationalizedCode, nationalizedCode ); + private NationalizedTypeMappings() { } public int getCorrespondingNationalizedCode(int jdbcCode) { - Integer nationalizedCode = nationalizedCodeByNonNationalized.get( jdbcCode ); - if ( nationalizedCode == null ) { - log.debug( "Unable to locate nationalized jdbc-code equivalent for given jdbc code : " + jdbcCode ); - return jdbcCode; + switch ( jdbcCode ) { + case Types.CHAR: return Types.NCHAR; + case Types.CLOB: return Types.NCLOB; + case Types.LONGVARCHAR: return Types.LONGNVARCHAR; + case Types.VARCHAR: return Types.NVARCHAR; + default: + throw new IllegalArgumentException( "Unable to locate nationalized jdbc-code equivalent for given jdbc code : " + jdbcCode ); } - return nationalizedCode; } }