Skip to content

Commit 9ca5bb1

Browse files
committed
rationalize one more Logger
1 parent a5a5bc3 commit 9ca5bb1

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

hibernate-core/src/main/java/org/hibernate/boot/jaxb/internal/stax/LocalSchemaLocator.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,8 @@ public static Schema resolveLocalSchema(URL schemaUrl) {
4848
try {
4949
final var schemaStream = schemaUrl.openStream();
5050
try {
51-
final var source = new StreamSource(schemaUrl.openStream());
52-
final var schemaFactory = SchemaFactory.newInstance( W3C_XML_SCHEMA_NS_URI );
53-
return schemaFactory.newSchema(source);
51+
return SchemaFactory.newInstance( W3C_XML_SCHEMA_NS_URI )
52+
.newSchema( new StreamSource( schemaUrl.openStream() ) );
5453
}
5554
catch ( Exception e ) {
5655
throw new XmlInfrastructureException( "Unable to load schema [" + schemaUrl.toExternalForm() + "]", e );

hibernate-core/src/main/java/org/hibernate/boot/xsd/LocalXsdResolver.java

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
import 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

Comments
 (0)