diff --git a/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java b/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java index c83e7046a9..d8b3d9a6fb 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java +++ b/spring-core/src/main/java/org/springframework/util/xml/AbstractStaxXMLReader.java @@ -64,22 +64,19 @@ abstract class AbstractStaxXMLReader extends AbstractXMLReader { @Override public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException { - if (NAMESPACES_FEATURE_NAME.equals(name)) { - return this.namespacesFeature; - } - else if (NAMESPACE_PREFIXES_FEATURE_NAME.equals(name)) { - return this.namespacePrefixesFeature; - } - else if (IS_STANDALONE_FEATURE_NAME.equals(name)) { - if (this.isStandalone != null) { - return this.isStandalone; - } - else { - throw new SAXNotSupportedException("startDocument() callback not completed yet"); - } - } - else { - return super.getFeature(name); + switch (name) { + case NAMESPACES_FEATURE_NAME: + return this.namespacesFeature; + case NAMESPACE_PREFIXES_FEATURE_NAME: + return this.namespacePrefixesFeature; + case IS_STANDALONE_FEATURE_NAME: + if (this.isStandalone != null) { + return this.isStandalone; + } else { + throw new SAXNotSupportedException("startDocument() callback not completed yet"); + } + default: + return super.getFeature(name); } } diff --git a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java index 0842d4c15f..f6a7a8b494 100644 --- a/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java +++ b/spring-jdbc/src/main/java/org/springframework/jdbc/datasource/DataSourceTransactionManager.java @@ -408,13 +408,9 @@ public class DataSourceTransactionManager extends AbstractPlatformTransactionMan throws SQLException { if (isEnforceReadOnly() && definition.isReadOnly()) { - Statement stmt = con.createStatement(); - try { + try (Statement stmt = con.createStatement()) { stmt.executeUpdate("SET TRANSACTION READ ONLY"); } - finally { - stmt.close(); - } } }