Skip to content

Commit 7324140

Browse files
committed
Merge branch '5.2.x'
2 parents 74a0147 + f43c39c commit 7324140

File tree

23 files changed

+79
-74
lines changed

23 files changed

+79
-74
lines changed

build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ configure(allprojects) { project ->
117117
dependency "net.sf.ehcache:ehcache:2.10.6"
118118
dependency "org.ehcache:jcache:1.0.1"
119119
dependency "org.ehcache:ehcache:3.4.0"
120-
dependency "org.hibernate:hibernate-core:5.4.19.Final"
120+
dependency "org.hibernate:hibernate-core:5.4.20.Final"
121121
dependency "org.hibernate:hibernate-validator:6.1.5.Final"
122122
dependency "org.webjars:webjars-locator-core:0.45"
123123
dependency "org.webjars:underscorejs:1.8.3"

spring-beans/src/main/java/org/springframework/beans/factory/config/ConstructorArgumentValues.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -164,10 +164,10 @@ public ValueHolder getIndexedArgumentValue(int index, @Nullable Class<?> require
164164
Assert.isTrue(index >= 0, "Index must not be negative");
165165
ValueHolder valueHolder = this.indexedArgumentValues.get(index);
166166
if (valueHolder != null &&
167-
(valueHolder.getType() == null ||
168-
(requiredType != null && ClassUtils.matchesTypeName(requiredType, valueHolder.getType()))) &&
169-
(valueHolder.getName() == null || "".equals(requiredName) ||
170-
(requiredName != null && requiredName.equals(valueHolder.getName())))) {
167+
(valueHolder.getType() == null || (requiredType != null &&
168+
ClassUtils.matchesTypeName(requiredType, valueHolder.getType()))) &&
169+
(valueHolder.getName() == null || (requiredName != null &&
170+
(requiredName.isEmpty() || requiredName.equals(valueHolder.getName()))))) {
171171
return valueHolder;
172172
}
173173
return null;
@@ -277,17 +277,19 @@ public ValueHolder getGenericArgumentValue(Class<?> requiredType, String require
277277
* @return the ValueHolder for the argument, or {@code null} if none found
278278
*/
279279
@Nullable
280-
public ValueHolder getGenericArgumentValue(@Nullable Class<?> requiredType, @Nullable String requiredName, @Nullable Set<ValueHolder> usedValueHolders) {
280+
public ValueHolder getGenericArgumentValue(@Nullable Class<?> requiredType, @Nullable String requiredName,
281+
@Nullable Set<ValueHolder> usedValueHolders) {
282+
281283
for (ValueHolder valueHolder : this.genericArgumentValues) {
282284
if (usedValueHolders != null && usedValueHolders.contains(valueHolder)) {
283285
continue;
284286
}
285-
if (valueHolder.getName() != null && !"".equals(requiredName) &&
286-
(requiredName == null || !valueHolder.getName().equals(requiredName))) {
287+
if (valueHolder.getName() != null && (requiredName == null ||
288+
(!requiredName.isEmpty() && !requiredName.equals(valueHolder.getName())))) {
287289
continue;
288290
}
289-
if (valueHolder.getType() != null &&
290-
(requiredType == null || !ClassUtils.matchesTypeName(requiredType, valueHolder.getType()))) {
291+
if (valueHolder.getType() != null && (requiredType == null ||
292+
!ClassUtils.matchesTypeName(requiredType, valueHolder.getType()))) {
291293
continue;
292294
}
293295
if (requiredType != null && valueHolder.getType() == null && valueHolder.getName() == null &&

spring-beans/src/main/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReader.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -449,8 +449,8 @@ else if (SCOPE_KEY.equals(property)) {
449449
else if (SINGLETON_KEY.equals(property)) {
450450
// Spring 1.2 style
451451
String val = StringUtils.trimWhitespace((String) entry.getValue());
452-
scope = ("".equals(val) || TRUE_VALUE.equals(val) ? BeanDefinition.SCOPE_SINGLETON :
453-
BeanDefinition.SCOPE_PROTOTYPE);
452+
scope = (!StringUtils.hasLength(val) || TRUE_VALUE.equals(val) ?
453+
BeanDefinition.SCOPE_SINGLETON : BeanDefinition.SCOPE_PROTOTYPE);
454454
}
455455
else if (LAZY_INIT_KEY.equals(property)) {
456456
String val = StringUtils.trimWhitespace((String) entry.getValue());

spring-beans/src/main/java/org/springframework/beans/factory/xml/BeanDefinitionParserDelegate.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ public boolean nodeNameEquals(Node node, String desiredName) {
15231523
* Determine whether the given URI indicates the default namespace.
15241524
*/
15251525
public boolean isDefaultNamespace(@Nullable String namespaceUri) {
1526-
return (!StringUtils.hasLength(namespaceUri) || BEANS_NAMESPACE_URI.equals(namespaceUri));
1526+
return !StringUtils.hasLength(namespaceUri) || BEANS_NAMESPACE_URI.equals(namespaceUri);
15271527
}
15281528

15291529
/**
@@ -1534,7 +1534,7 @@ public boolean isDefaultNamespace(Node node) {
15341534
}
15351535

15361536
private boolean isDefaultValue(String value) {
1537-
return (DEFAULT_VALUE.equals(value) || "".equals(value));
1537+
return !StringUtils.hasLength(value) || DEFAULT_VALUE.equals(value);
15381538
}
15391539

15401540
private boolean isCandidateElement(Node node) {

spring-context/src/main/java/org/springframework/context/support/AbstractResourceBasedMessageSource.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ protected Locale getDefaultLocale() {
218218
* a non-classpath location.
219219
*/
220220
public void setCacheSeconds(int cacheSeconds) {
221-
this.cacheMillis = (cacheSeconds * 1000);
221+
this.cacheMillis = cacheSeconds * 1000L;
222222
}
223223

224224
/**

spring-context/src/main/java/org/springframework/scheduling/concurrent/ExecutorConfigurationSupport.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void setWaitForTasksToCompleteOnShutdown(boolean waitForJobsToCompleteOnS
146146
* @see java.util.concurrent.ExecutorService#awaitTermination
147147
*/
148148
public void setAwaitTerminationSeconds(int awaitTerminationSeconds) {
149-
this.awaitTerminationMillis = awaitTerminationSeconds * 1000;
149+
this.awaitTerminationMillis = awaitTerminationSeconds * 1000L;
150150
}
151151

152152
/**

spring-context/src/main/java/org/springframework/validation/AbstractBindingResult.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -105,7 +105,7 @@ public void reject(String errorCode, @Nullable Object[] errorArgs, @Nullable Str
105105
public void rejectValue(@Nullable String field, String errorCode, @Nullable Object[] errorArgs,
106106
@Nullable String defaultMessage) {
107107

108-
if ("".equals(getNestedPath()) && !StringUtils.hasLength(field)) {
108+
if (!StringUtils.hasLength(getNestedPath()) && !StringUtils.hasLength(field)) {
109109
// We're at the top of the nested object hierarchy,
110110
// so the present level is not a field but rather the top object.
111111
// The best we can do is register a global error here...

spring-context/src/main/java/org/springframework/validation/beanvalidation/SpringValidatorAdapter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -311,7 +311,7 @@ protected MessageSourceResolvable getResolvableField(String objectName, String f
311311
@Nullable
312312
protected Object getRejectedValue(String field, ConstraintViolation<Object> violation, BindingResult bindingResult) {
313313
Object invalidValue = violation.getInvalidValue();
314-
if (!"".equals(field) && !field.contains("[]") &&
314+
if (!field.isEmpty() && !field.contains("[]") &&
315315
(invalidValue == violation.getLeafBean() || field.contains("[") || field.contains("."))) {
316316
// Possibly a bean constraint with property path: retrieve the actual property value.
317317
// However, explicitly avoid this for "address[]" style paths that we can't handle.

spring-context/src/testFixtures/java/org/springframework/context/testfixture/jndi/SimpleNamingContext.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -126,7 +126,7 @@ public Object lookup(String lookupName) throws NameNotFoundException {
126126
if (logger.isDebugEnabled()) {
127127
logger.debug("Static JNDI lookup: [" + name + "]");
128128
}
129-
if ("".equals(name)) {
129+
if (name.isEmpty()) {
130130
return new SimpleNamingContext(this.root, this.boundObjects, this.environment);
131131
}
132132
Object found = this.boundObjects.get(name);
@@ -303,10 +303,10 @@ public Name composeName(Name name, Name prefix) throws NamingException {
303303

304304
private abstract static class AbstractNamingEnumeration<T> implements NamingEnumeration<T> {
305305

306-
private Iterator<T> iterator;
306+
private final Iterator<T> iterator;
307307

308308
private AbstractNamingEnumeration(SimpleNamingContext context, String proot) throws NamingException {
309-
if (!"".equals(proot) && !proot.endsWith("/")) {
309+
if (!proot.isEmpty() && !proot.endsWith("/")) {
310310
proot = proot + "/";
311311
}
312312
String root = context.root + proot;

spring-core/src/main/java/org/springframework/core/io/support/PathMatchingResourcePatternResolver.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -340,7 +340,7 @@ protected Set<Resource> doFindAllClassPathResources(String path) throws IOExcept
340340
URL url = resourceUrls.nextElement();
341341
result.add(convertClassLoaderURL(url));
342342
}
343-
if ("".equals(path)) {
343+
if (!StringUtils.hasLength(path)) {
344344
// The above result is likely to be incomplete, i.e. only containing file system references.
345345
// We need to have pointers to each of the jar files on the classpath as well...
346346
addAllClassLoaderJarRoots(cl, result);
@@ -639,7 +639,7 @@ protected Set<Resource> doFindPathMatchingJarResources(Resource rootDirResource,
639639
if (logger.isTraceEnabled()) {
640640
logger.trace("Looking for matching resources in jar file [" + jarFileUrl + "]");
641641
}
642-
if (!"".equals(rootEntryPath) && !rootEntryPath.endsWith("/")) {
642+
if (StringUtils.hasLength(rootEntryPath) && !rootEntryPath.endsWith("/")) {
643643
// Root entry path must end with slash to allow for proper matching.
644644
// The Sun JRE does not return a slash here, but BEA JRockit does.
645645
rootEntryPath = rootEntryPath + "/";

spring-core/src/main/java/org/springframework/util/StringUtils.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,16 @@ public static String trimTrailingCharacter(String str, char trailingCharacter) {
331331
return sb.toString();
332332
}
333333

334+
/**
335+
* Test if the given {@code String} matches the given single character.
336+
* @param str the {@code String} to check
337+
* @param singleCharacter the character to compare to
338+
* @since 5.2.9
339+
*/
340+
public static boolean matchesCharacter(@Nullable String str, char singleCharacter) {
341+
return (str != null && str.length() == 1 && str.charAt(0) == singleCharacter);
342+
}
343+
334344
/**
335345
* Test if the given {@code String} starts with the specified prefix,
336346
* ignoring upper/lower case.
@@ -716,7 +726,7 @@ else if (TOP_PATH.equals(element)) {
716726
pathElements.add(0, TOP_PATH);
717727
}
718728
// If nothing else left, at least explicitly point to current path.
719-
if (pathElements.size() == 1 && "".equals(pathElements.getLast()) && !prefix.endsWith(FOLDER_SEPARATOR)) {
729+
if (pathElements.size() == 1 && pathElements.getLast().isEmpty() && !prefix.endsWith(FOLDER_SEPARATOR)) {
720730
pathElements.add(0, CURRENT_PATH);
721731
}
722732

spring-jms/src/main/java/org/springframework/jms/config/AbstractListenerContainerParser.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -255,7 +255,7 @@ else if (DESTINATION_TYPE_DURABLE_TOPIC.equals(destinationType)) {
255255
else if (DESTINATION_TYPE_TOPIC.equals(destinationType)) {
256256
pubSubDomain = true;
257257
}
258-
else if ("".equals(destinationType) || DESTINATION_TYPE_QUEUE.equals(destinationType)) {
258+
else if (!StringUtils.hasLength(destinationType) || DESTINATION_TYPE_QUEUE.equals(destinationType)) {
259259
// the default: queue
260260
}
261261
else {

spring-jms/src/main/java/org/springframework/jms/config/JmsListenerContainerParser.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -64,10 +64,10 @@ protected RootBeanDefinition createContainerFactory(String factoryId, Element co
6464

6565
String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE);
6666
String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
67-
if (!"".equals(containerClass)) {
68-
return null; // Not supported
67+
if (StringUtils.hasLength(containerClass)) {
68+
return null; // not supported
6969
}
70-
else if ("".equals(containerType) || containerType.startsWith("default")) {
70+
else if (!StringUtils.hasLength(containerType) || containerType.startsWith("default")) {
7171
factoryDef.setBeanClassName("org.springframework.jms.config.DefaultJmsListenerContainerFactory");
7272
}
7373
else if (containerType.startsWith("simple")) {
@@ -91,10 +91,10 @@ protected RootBeanDefinition createContainer(Element containerEle, Element liste
9191

9292
String containerType = containerEle.getAttribute(CONTAINER_TYPE_ATTRIBUTE);
9393
String containerClass = containerEle.getAttribute(CONTAINER_CLASS_ATTRIBUTE);
94-
if (!"".equals(containerClass)) {
94+
if (StringUtils.hasLength(containerClass)) {
9595
containerDef.setBeanClassName(containerClass);
9696
}
97-
else if ("".equals(containerType) || containerType.startsWith("default")) {
97+
else if (!StringUtils.hasLength(containerType) || containerType.startsWith("default")) {
9898
containerDef.setBeanClassName("org.springframework.jms.listener.DefaultMessageListenerContainer");
9999
}
100100
else if (containerType.startsWith("simple")) {

spring-test/src/main/java/org/springframework/mock/jndi/SimpleNamingContext.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -303,7 +303,7 @@ public Name composeName(Name name, Name prefix) throws NamingException {
303303

304304
private abstract static class AbstractNamingEnumeration<T> implements NamingEnumeration<T> {
305305

306-
private Iterator<T> iterator;
306+
private final Iterator<T> iterator;
307307

308308
private AbstractNamingEnumeration(SimpleNamingContext context, String proot) throws NamingException {
309309
if (!proot.isEmpty() && !proot.endsWith("/")) {

spring-test/src/main/java/org/springframework/test/context/jdbc/MergedSqlConfig.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -235,7 +235,7 @@ private static <E extends Enum<?>> E getEnum(AnnotationAttributes attributes, St
235235

236236
private static String getString(AnnotationAttributes attributes, String attributeName, String defaultValue) {
237237
String value = attributes.getString(attributeName);
238-
if ("".equals(value)) {
238+
if (value.isEmpty()) {
239239
value = defaultValue;
240240
}
241241
return value;

0 commit comments

Comments
 (0)