From fbd7fe000ea33e9bcd4e3354a74cd59cc4961e4c Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Mon, 18 Jul 2022 16:29:20 +0100 Subject: [PATCH] HHH-15409 Restore lazy initialization semantics for MetadataSources#xmlMappingBinderAccess --- .../org/hibernate/boot/MetadataSources.java | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java b/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java index aaf1eef24d..b91ac69eb0 100644 --- a/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java +++ b/hibernate-core/src/main/java/org/hibernate/boot/MetadataSources.java @@ -63,7 +63,7 @@ public class MetadataSources implements Serializable { private final ServiceRegistry serviceRegistry; private final ClassLoaderService classLoaderService; - private final XmlMappingBinderAccess xmlMappingBinderAccess; + private XmlMappingBinderAccess xmlMappingBinderAccess; private List> xmlBindings; private LinkedHashSet> annotatedClasses; @@ -85,7 +85,7 @@ public class MetadataSources implements Serializable { * @param serviceRegistry The service registry to use. */ public MetadataSources(ServiceRegistry serviceRegistry) { - this( serviceRegistry, new XmlMappingBinderAccess( serviceRegistry ) ); + this( serviceRegistry, null ); } /** @@ -109,24 +109,15 @@ public class MetadataSources implements Serializable { this.xmlMappingBinderAccess = xmlMappingBinderAccess; } - /** - * Consider this an SPI, used by Quarkus - */ - public MetadataSources(ServiceRegistry serviceRegistry, boolean disableXmlMappingBinders) { - Objects.requireNonNull( serviceRegistry ); - this.serviceRegistry = serviceRegistry; - this.classLoaderService = serviceRegistry.getService( ClassLoaderService.class ); - this.xmlMappingBinderAccess = disableXmlMappingBinders - ? null - : new XmlMappingBinderAccess( serviceRegistry ); - } - protected static boolean isExpectedServiceRegistryType(ServiceRegistry serviceRegistry) { return serviceRegistry instanceof BootstrapServiceRegistry || serviceRegistry instanceof StandardServiceRegistry; } public XmlMappingBinderAccess getXmlMappingBinderAccess() { + if ( xmlMappingBinderAccess == null ) { + xmlMappingBinderAccess = new XmlMappingBinderAccess( serviceRegistry ); + } return xmlMappingBinderAccess; }