diff --git a/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java
index d606231a131..8417b18ffa2 100644
--- a/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java
+++ b/spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java
@@ -55,7 +55,7 @@ public abstract class AbstractResourceBasedMessageSource extends AbstractMessage
* Set a single basename, following the basic ResourceBundle convention
* of not specifying file extension or language codes. The resource location
* format is up to the specific {@code MessageSource} implementation.
- *
Regular and XMl properties files are supported: for example, "messages" will find
+ *
Regular and XML properties files are supported: for example, "messages" will find
* a "messages.properties", "messages_en.properties" etc arrangement as well
* as "messages.xml", "messages_en.xml" etc.
* @param basename the single basename
diff --git a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java
index 4cfd9a03882..851aeed9da9 100644
--- a/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java
+++ b/spring-context/src/main/java/org/springframework/context/support/ReloadableResourceBundleMessageSource.java
@@ -95,10 +95,12 @@ import org.springframework.util.StringUtils;
public class ReloadableResourceBundleMessageSource extends AbstractResourceBasedMessageSource
implements ResourceLoaderAware {
+ private static final String PROPERTIES_EXTENSION = ".properties";
+
private static final String XML_EXTENSION = ".xml";
- private List fileExtensions = List.of(".properties", XML_EXTENSION);
+ private List fileExtensions = List.of(PROPERTIES_EXTENSION, XML_EXTENSION);
private @Nullable Properties fileEncodings;
@@ -380,18 +382,18 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
StringBuilder temp = new StringBuilder(basename);
temp.append('_');
- if (language.length() > 0) {
+ if (!language.isEmpty()) {
temp.append(language);
result.add(0, temp.toString());
}
temp.append('_');
- if (country.length() > 0) {
+ if (!country.isEmpty()) {
temp.append(country);
result.add(0, temp.toString());
}
- if (variant.length() > 0 && (language.length() > 0 || country.length() > 0)) {
+ if (!variant.isEmpty() && (!language.isEmpty() || !country.isEmpty())) {
temp.append('_').append(variant);
result.add(0, temp.toString());
}
@@ -560,13 +562,13 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
*/
protected Properties loadProperties(Resource resource, String filename) throws IOException {
Properties props = newProperties();
- try (InputStream is = resource.getInputStream()) {
+ try (InputStream inputStream = resource.getInputStream()) {
String resourceFilename = resource.getFilename();
if (resourceFilename != null && resourceFilename.endsWith(XML_EXTENSION)) {
if (logger.isDebugEnabled()) {
logger.debug("Loading properties [" + resource.getFilename() + "]");
}
- this.propertiesPersister.loadFromXml(props, is);
+ this.propertiesPersister.loadFromXml(props, inputStream);
}
else {
Charset charset = null;
@@ -583,13 +585,13 @@ public class ReloadableResourceBundleMessageSource extends AbstractResourceBased
if (logger.isDebugEnabled()) {
logger.debug("Loading properties [" + resource.getFilename() + "] with encoding '" + charset + "'");
}
- this.propertiesPersister.load(props, new InputStreamReader(is, charset));
+ this.propertiesPersister.load(props, new InputStreamReader(inputStream, charset));
}
else {
if (logger.isDebugEnabled()) {
logger.debug("Loading properties [" + resource.getFilename() + "]");
}
- this.propertiesPersister.load(props, is);
+ this.propertiesPersister.load(props, inputStream);
}
}
return props;
diff --git a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java
index 941d9e54916..a18047a1e93 100644
--- a/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java
+++ b/spring-orm/src/main/java/org/springframework/orm/jpa/persistenceunit/PersistenceUnitReader.java
@@ -114,21 +114,12 @@ final class PersistenceUnitReader {
}
- /**
- * Parse and build all persistence unit infos defined in the specified XML file(s).
- * @param persistenceXmlLocation the resource location (can be a pattern)
- * @return the resulting PersistenceUnitInfo instances
- */
- public SpringPersistenceUnitInfo[] readPersistenceUnitInfos(String persistenceXmlLocation) {
- return readPersistenceUnitInfos(new String[] {persistenceXmlLocation});
- }
-
/**
* Parse and build all persistence unit infos defined in the given XML files.
* @param persistenceXmlLocations the resource locations (can be patterns)
* @return the resulting PersistenceUnitInfo instances
*/
- public SpringPersistenceUnitInfo[] readPersistenceUnitInfos(String[] persistenceXmlLocations) {
+ public SpringPersistenceUnitInfo[] readPersistenceUnitInfos(String... persistenceXmlLocations) {
ErrorHandler handler = new SimpleSaxErrorHandler(logger);
List infos = new ArrayList<>(1);
String resourceLocation = null;