diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java index c386875ee10..a476de69cca 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StringToBooleanConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,9 +30,9 @@ import org.springframework.core.convert.converter.Converter; */ final class StringToBooleanConverter implements Converter { - private static final Set trueValues = new HashSet<>(4); + private static final Set trueValues = new HashSet<>(8); - private static final Set falseValues = new HashSet<>(4); + private static final Set falseValues = new HashSet<>(8); static { trueValues.add("true"); @@ -46,10 +46,11 @@ final class StringToBooleanConverter implements Converter { falseValues.add("0"); } + @Override public Boolean convert(String source) { String value = source.trim(); - if ("".equals(value)) { + if (value.isEmpty()) { return null; } value = value.toLowerCase(); diff --git a/spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java b/spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java index 00d48b22a89..794450cbd08 100644 --- a/spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java +++ b/spring-core/src/main/java/org/springframework/core/convert/support/StringToUUIDConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.springframework.core.convert.support; import java.util.UUID; import org.springframework.core.convert.converter.Converter; +import org.springframework.lang.Nullable; import org.springframework.util.StringUtils; /** @@ -31,6 +32,7 @@ import org.springframework.util.StringUtils; final class StringToUUIDConverter implements Converter { @Override + @Nullable public UUID convert(String source) { return (StringUtils.hasLength(source) ? UUID.fromString(source.trim()) : null); } diff --git a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java index 1a6fab102b3..068ec0dd934 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java @@ -369,10 +369,10 @@ public final class ContentDisposition { } /** - * Decode the given header field param as describe in RFC 5987. + * Decode the given header field param as described in RFC 5987. *

Only the US-ASCII, UTF-8 and ISO-8859-1 charsets are supported. - * @param filename the header field param - * @param charset the charset to use + * @param filename the filename + * @param charset the charset for the filename * @return the encoded header field param * @see RFC 5987 */ @@ -380,18 +380,18 @@ public final class ContentDisposition { Assert.notNull(filename, "'input' String` should not be null"); Assert.notNull(charset, "'charset' should not be null"); byte[] value = filename.getBytes(charset); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); + ByteArrayOutputStream baos = new ByteArrayOutputStream(); int index = 0; while (index < value.length) { byte b = value[index]; if (isRFC5987AttrChar(b)) { - bos.write((char) b); + baos.write((char) b); index++; } else if (b == '%' && index < value.length - 2) { char[] array = new char[]{(char) value[index + 1], (char) value[index + 2]}; try { - bos.write(Integer.parseInt(String.valueOf(array), 16)); + baos.write(Integer.parseInt(String.valueOf(array), 16)); } catch (NumberFormatException ex) { throw new IllegalArgumentException(INVALID_HEADER_FIELD_PARAMETER_FORMAT, ex); @@ -402,7 +402,7 @@ public final class ContentDisposition { throw new IllegalArgumentException(INVALID_HEADER_FIELD_PARAMETER_FORMAT); } } - return new String(bos.toByteArray(), charset); + return new String(baos.toByteArray(), charset); } private static boolean isRFC5987AttrChar(byte c) { @@ -522,7 +522,7 @@ public final class ContentDisposition { private static class BuilderImpl implements Builder { - private String type; + private final String type; @Nullable private String name; diff --git a/src/docs/asciidoc/core/core-aop-api.adoc b/src/docs/asciidoc/core/core-aop-api.adoc index ad5c5e1bd3f..95f070319ea 100644 --- a/src/docs/asciidoc/core/core-aop-api.adoc +++ b/src/docs/asciidoc/core/core-aop-api.adoc @@ -149,11 +149,11 @@ Let's consider some static pointcut implementations included with Spring. One obvious way to specify static pointcuts is regular expressions. Several AOP frameworks besides Spring make this possible. `org.springframework.aop.support.JdkRegexpMethodPointcut` is a generic regular -expression pointcut, using the regular expression support in the JDK. +expression pointcut that uses the regular expression support in the JDK. -Using the `JdkRegexpMethodPointcut` class, you can provide a list of pattern Strings. If -any of these is a match, the pointcut will evaluate to true. (So the result is -effectively the union of these pointcuts.) +With the `JdkRegexpMethodPointcut` class, you can provide a list of pattern strings. +If any of these is a match, the pointcut evaluates to `true`. (As a consequence, +the resulting pointcut is effectively the union of the specified patterns.) The usage is shown below: diff --git a/src/docs/asciidoc/core/core-aop.adoc b/src/docs/asciidoc/core/core-aop.adoc index 6aac375ea9c..604244107b6 100644 --- a/src/docs/asciidoc/core/core-aop.adoc +++ b/src/docs/asciidoc/core/core-aop.adoc @@ -1359,7 +1359,7 @@ join point, unless you specify otherwise the order of execution is undefined. Yo control the order of execution by specifying precedence. This is done in the normal Spring way by either implementing the `org.springframework.core.Ordered` interface in the aspect class or annotating it with the `Order` annotation. Given two aspects, the -aspect returning the lower value from `Ordered.getValue()` (or the annotation value) has +aspect returning the lower value from `Ordered.getOrder()` (or the annotation value) has the higher precedence. When two pieces of advice defined in __the same__ aspect both need to run at the same diff --git a/src/docs/asciidoc/core/core-beans.adoc b/src/docs/asciidoc/core/core-beans.adoc index ccb16524fe3..3d9ac53aa08 100644 --- a/src/docs/asciidoc/core/core-beans.adoc +++ b/src/docs/asciidoc/core/core-beans.adoc @@ -39,7 +39,7 @@ information on using the `BeanFactory` instead of the `ApplicationContext,` refe In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC __container__ are called __beans__. A bean is an object that is -instantiated, assembled, and otherwise managed by a Spring IoC container. Otherwise, a +instantiated, assembled, and managed by a Spring IoC container. Otherwise, a bean is simply one of many objects in your application. Beans, and the __dependencies__ among them, are reflected in the __configuration metadata__ used by a container.