1818
1919import  org .xml .sax .SAXException ;
2020
21+ import  static  javax .xml .XMLConstants .W3C_XML_SCHEMA_NS_URI ;
22+ import  static  org .hibernate .boot .jaxb .JaxbLogger .JAXB_LOGGER ;
23+ 
2124/** 
2225 * When Hibernate loads an XSD we fully expect that to be resolved from our 
2326 * jar file via ClassLoader resource look-up.  This class simplifies 
@@ -33,18 +36,10 @@ public static String latestJpaVerison() {
3336	}
3437
3538	public  static  boolean  isValidJpaVersion (String  version ) {
36- 		switch  ( version  ) {
37- 			case  "1.0" :
38- 			case  "2.0" :
39- 			case  "2.1" :
40- 			case  "2.2" :
41- 			case  "3.0" :
42- 			case  "3.1" :
43- 			case  "3.2" :
44- 				return  true ;
45- 			default :
46- 				return  false ;
47- 		}
39+ 		return  switch  ( version  ) {
40+ 			case  "1.0" , "2.0" , "2.1" , "2.2" , "3.0" , "3.1" , "3.2"  -> true ;
41+ 			default  -> false ;
42+ 		};
4843	}
4944
5045	public  static  URL  resolveLocalXsdUrl (String  resourceName ) {
@@ -87,11 +82,10 @@ public static Schema resolveLocalXsdSchema(String schemaResourceName) {
8782			throw  new  XsdException ( "Unable to locate schema ["  + schemaResourceName  + "] via classpath" , schemaResourceName  );
8883		}
8984		try  {
90- 			InputStream  schemaStream  = url .openStream ();
85+ 			final   var  schemaStream  = url .openStream ();
9186			try  {
92- 				StreamSource  source  = new  StreamSource ( url .openStream () );
93- 				SchemaFactory  schemaFactory  = SchemaFactory .newInstance ( XMLConstants .W3C_XML_SCHEMA_NS_URI  );
94- 				return  schemaFactory .newSchema ( source  );
87+ 				return  SchemaFactory .newInstance ( W3C_XML_SCHEMA_NS_URI  )
88+ 						.newSchema ( new  StreamSource ( url .openStream () ) );
9589			}
9690			catch  ( SAXException  | IOException  e  ) {
9791				throw  new  XsdException ( "Unable to load schema ["  + schemaResourceName  + "]" , e , schemaResourceName  );
@@ -101,8 +95,7 @@ public static Schema resolveLocalXsdSchema(String schemaResourceName) {
10195					schemaStream .close ();
10296				}
10397				catch  ( IOException  e  ) {
104- 					Logger .getLogger ( LocalXsdResolver .class  )
105- 							.debugf ( "Problem closing schema stream [%s]" , e .toString () );
98+ 					JAXB_LOGGER .problemClosingSchemaStream ( e .toString () );
10699				}
107100			}
108101		}
0 commit comments