Skip to content

Commit

Permalink
HHH-11495 Only cache values if the class is mapped somehow
Browse files Browse the repository at this point in the history
  • Loading branch information
gsmet committed Jul 3, 2018
1 parent 7067b19 commit 6c5e71f
Showing 1 changed file with 8 additions and 2 deletions.
Expand Up @@ -80,6 +80,7 @@ public class MetamodelImpl implements MetamodelImplementor, Serializable {
private static final EntityManagerMessageLogger log = HEMLogging.messageLogger( MetamodelImpl.class );
private static final Object ENTITY_NAME_RESOLVER_MAP_VALUE = new Object();
private static final String INVALID_IMPORT = "";
private static final String[] EMPTY_IMPLEMENTORS = new String[0];

private final SessionFactoryImplementor sessionFactory;

Expand Down Expand Up @@ -635,8 +636,13 @@ public String[] getImplementors(String className) throws MappingException {
try {
final Class<?> clazz = getSessionFactory().getServiceRegistry().getService( ClassLoaderService.class ).classForName( className );
implementors = doGetImplementors( clazz );
implementorsCache.putIfAbsent( className, implementors );
return Arrays.copyOf( implementors, implementors.length );
if ( implementors.length > 0 ) {
implementorsCache.putIfAbsent( className, implementors );
return Arrays.copyOf( implementors, implementors.length );
}
else {
return EMPTY_IMPLEMENTORS;
}
}
catch (ClassLoadingException e) {
return new String[]{ className }; // we don't cache anything for dynamic classes
Expand Down

0 comments on commit 6c5e71f

Please sign in to comment.