diff --git a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java index 396bc0b518..7f0544e139 100644 --- a/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java +++ b/spring-core/src/main/java/org/springframework/util/AntPathMatcher.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -402,7 +402,7 @@ public class AntPathMatcher implements PathMatcher { protected String[] tokenizePattern(String pattern) { String[] tokenized = null; Boolean cachePatterns = this.cachePatterns; - if (cachePatterns == null || cachePatterns.booleanValue()) { + if (cachePatterns == null || cachePatterns) { tokenized = this.tokenizedPatternCache.get(pattern); } if (tokenized == null) { @@ -414,7 +414,7 @@ public class AntPathMatcher implements PathMatcher { deactivatePatternCache(); return tokenized; } - if (cachePatterns == null || cachePatterns.booleanValue()) { + if (cachePatterns == null || cachePatterns) { this.tokenizedPatternCache.put(pattern, tokenized); } } @@ -458,7 +458,7 @@ public class AntPathMatcher implements PathMatcher { protected AntPathStringMatcher getStringMatcher(String pattern) { AntPathStringMatcher matcher = null; Boolean cachePatterns = this.cachePatterns; - if (cachePatterns == null || cachePatterns.booleanValue()) { + if (cachePatterns == null || cachePatterns) { matcher = this.stringMatcherCache.get(pattern); } if (matcher == null) { @@ -470,7 +470,7 @@ public class AntPathMatcher implements PathMatcher { deactivatePatternCache(); return matcher; } - if (cachePatterns == null || cachePatterns.booleanValue()) { + if (cachePatterns == null || cachePatterns) { this.stringMatcherCache.put(pattern, matcher); } } diff --git a/spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java b/spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java index ff966cd292..4a01bd5021 100644 --- a/spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java +++ b/spring-core/src/main/java/org/springframework/util/AutoPopulatingList.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2023 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. @@ -138,7 +138,7 @@ public class AutoPopulatingList implements List, Serializable { @Override public E get(int index) { int backingListSize = this.backingList.size(); - E element = null; + E element; if (index < backingListSize) { element = this.backingList.get(index); if (element == null) { diff --git a/spring-core/src/main/java/org/springframework/util/Base64Utils.java b/spring-core/src/main/java/org/springframework/util/Base64Utils.java index 0403c29990..49cdef9896 100644 --- a/spring-core/src/main/java/org/springframework/util/Base64Utils.java +++ b/spring-core/src/main/java/org/springframework/util/Base64Utils.java @@ -98,7 +98,7 @@ public abstract class Base64Utils { } /** - * Base64-decode the given byte array from an UTF-8 String. + * Base64-decode the given byte array from a UTF-8 String. * @param src the encoded UTF-8 String * @return the original byte array */ @@ -120,7 +120,7 @@ public abstract class Base64Utils { } /** - * Base64-decode the given byte array from an UTF-8 String using the RFC 4648 + * Base64-decode the given byte array from a UTF-8 String using the RFC 4648 * "URL and Filename Safe Alphabet". * @param src the encoded UTF-8 String * @return the original byte array diff --git a/spring-core/src/main/java/org/springframework/util/ClassUtils.java b/spring-core/src/main/java/org/springframework/util/ClassUtils.java index f68e252bd1..77fa719717 100644 --- a/spring-core/src/main/java/org/springframework/util/ClassUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ClassUtils.java @@ -106,19 +106,19 @@ public abstract class ClassUtils { /** * Map with primitive wrapper type as key and corresponding primitive - * type as value, for example: Integer.class -> int.class. + * type as value, for example: {@code Integer.class -> int.class}. */ private static final Map, Class> primitiveWrapperTypeMap = new IdentityHashMap<>(9); /** * Map with primitive type as key and corresponding wrapper - * type as value, for example: int.class -> Integer.class. + * type as value, for example: {@code int.class -> Integer.class}. */ private static final Map, Class> primitiveTypeToWrapperMap = new IdentityHashMap<>(9); /** * Map with primitive type name as key and corresponding primitive - * type as value, for example: "int" -> "int.class". + * type as value, for example: {@code "int" -> int.class}. */ private static final Map> primitiveTypeNameMap = new HashMap<>(32); diff --git a/spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java b/spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java index a46c1e8a7d..6ab26b8f61 100644 --- a/spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java +++ b/spring-core/src/main/java/org/springframework/util/ConcurrentLruCache.java @@ -396,7 +396,6 @@ public final class ConcurrentLruCache { private final EvictionQueue evictionQueue; - @SuppressWarnings("rawtypes") ReadOperations(EvictionQueue evictionQueue) { this.evictionQueue = evictionQueue; for (int i = 0; i < BUFFER_COUNT; i++) { diff --git a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java index 7dcebf7a68..4e773adc01 100644 --- a/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java +++ b/spring-core/src/main/java/org/springframework/util/ConcurrentReferenceHashMap.java @@ -317,7 +317,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen } @Override - public boolean remove(@Nullable Object key, final @Nullable Object value) { + public boolean remove(@Nullable Object key, @Nullable final Object value) { Boolean result = doTask(key, new Task(TaskOption.RESTRUCTURE_AFTER, TaskOption.SKIP_IF_EMPTY) { @Override protected Boolean execute(@Nullable Reference ref, @Nullable Entry entry) { @@ -334,7 +334,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen } @Override - public boolean replace(@Nullable K key, final @Nullable V oldValue, final @Nullable V newValue) { + public boolean replace(@Nullable K key, @Nullable final V oldValue, @Nullable final V newValue) { Boolean result = doTask(key, new Task(TaskOption.RESTRUCTURE_BEFORE, TaskOption.SKIP_IF_EMPTY) { @Override protected Boolean execute(@Nullable Reference ref, @Nullable Entry entry) { @@ -350,7 +350,7 @@ public class ConcurrentReferenceHashMap extends AbstractMap implemen @Override @Nullable - public V replace(@Nullable K key, final @Nullable V value) { + public V replace(@Nullable K key, @Nullable final V value) { return doTask(key, new Task(TaskOption.RESTRUCTURE_BEFORE, TaskOption.SKIP_IF_EMPTY) { @Override @Nullable diff --git a/spring-core/src/main/java/org/springframework/util/DigestUtils.java b/spring-core/src/main/java/org/springframework/util/DigestUtils.java index 63554c65b2..ce1a7d5184 100644 --- a/spring-core/src/main/java/org/springframework/util/DigestUtils.java +++ b/spring-core/src/main/java/org/springframework/util/DigestUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -125,13 +125,13 @@ public abstract class DigestUtils { private static byte[] digest(String algorithm, InputStream inputStream) throws IOException { MessageDigest messageDigest = getDigest(algorithm); - if (inputStream instanceof UpdateMessageDigestInputStream digestIntputStream){ - digestIntputStream.updateMessageDigest(messageDigest); + if (inputStream instanceof UpdateMessageDigestInputStream digestInputStream){ + digestInputStream.updateMessageDigest(messageDigest); return messageDigest.digest(); } else { final byte[] buffer = new byte[StreamUtils.BUFFER_SIZE]; - int bytesRead = -1; + int bytesRead; while ((bytesRead = inputStream.read(buffer)) != -1) { messageDigest.update(buffer, 0, bytesRead); } diff --git a/spring-core/src/main/java/org/springframework/util/FileSystemUtils.java b/spring-core/src/main/java/org/springframework/util/FileSystemUtils.java index b931a07295..d060c1c118 100644 --- a/spring-core/src/main/java/org/springframework/util/FileSystemUtils.java +++ b/spring-core/src/main/java/org/springframework/util/FileSystemUtils.java @@ -84,12 +84,13 @@ public abstract class FileSystemUtils { return false; } - Files.walkFileTree(root, new SimpleFileVisitor() { + Files.walkFileTree(root, new SimpleFileVisitor<>() { @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.delete(file); return FileVisitResult.CONTINUE; } + @Override public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { Files.delete(dir); @@ -126,12 +127,13 @@ public abstract class FileSystemUtils { BasicFileAttributes srcAttr = Files.readAttributes(src, BasicFileAttributes.class); if (srcAttr.isDirectory()) { - Files.walkFileTree(src, EnumSet.of(FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor() { + Files.walkFileTree(src, EnumSet.of(FOLLOW_LINKS), Integer.MAX_VALUE, new SimpleFileVisitor<>() { @Override public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs) throws IOException { Files.createDirectories(dest.resolve(src.relativize(dir))); return FileVisitResult.CONTINUE; } + @Override public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException { Files.copy(file, dest.resolve(src.relativize(file)), StandardCopyOption.REPLACE_EXISTING); diff --git a/spring-core/src/main/java/org/springframework/util/MimeType.java b/spring-core/src/main/java/org/springframework/util/MimeType.java index 1043279d96..a178489598 100644 --- a/spring-core/src/main/java/org/springframework/util/MimeType.java +++ b/spring-core/src/main/java/org/springframework/util/MimeType.java @@ -102,7 +102,6 @@ public class MimeType implements Comparable, Serializable { private final String subtype; - @SuppressWarnings("serial") private final Map parameters; @Nullable @@ -642,7 +641,7 @@ public class MimeType implements Comparable, Serializable { } /** - * Indicates whether this {@code MimeType} is more less than the given type. + * Indicates whether this {@code MimeType} is less specific than the given type. *
    *
  1. if this mime type has a {@linkplain #isWildcardType() wildcard type}, * and the other does not, then this method returns {@code true}.
  2. @@ -684,7 +683,7 @@ public class MimeType implements Comparable, Serializable { /** * Parse the given String value into a {@code MimeType} object, * with this method name following the 'valueOf' naming convention - * (as supported by {@link org.springframework.core.convert.ConversionService}. + * (as supported by {@link org.springframework.core.convert.ConversionService}). * @see MimeTypeUtils#parseMimeType(String) */ public static MimeType valueOf(String value) { diff --git a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java index 1f1fa1f903..8657738dc6 100644 --- a/spring-core/src/main/java/org/springframework/util/ObjectUtils.java +++ b/spring-core/src/main/java/org/springframework/util/ObjectUtils.java @@ -144,7 +144,7 @@ public abstract class ObjectUtils { return optional.isEmpty(); } if (obj instanceof CharSequence charSequence) { - return charSequence.length() == 0; + return charSequence.isEmpty(); } if (obj.getClass().isArray()) { return Array.getLength(obj) == 0; diff --git a/spring-core/src/main/java/org/springframework/util/StringUtils.java b/spring-core/src/main/java/org/springframework/util/StringUtils.java index 8936c605ba..440753b827 100644 --- a/spring-core/src/main/java/org/springframework/util/StringUtils.java +++ b/spring-core/src/main/java/org/springframework/util/StringUtils.java @@ -839,7 +839,7 @@ public abstract class StringUtils { * the {@link Locale#toString} format as well as BCP 47 language tags as * specified by {@link Locale#forLanguageTag}. * @param localeValue the locale value: following either {@code Locale's} - * {@code toString()} format ("en", "en_UK", etc), also accepting spaces as + * {@code toString()} format ("en", "en_UK", etc.), also accepting spaces as * separators (as an alternative to underscores), or BCP 47 (e.g. "en-UK") * @return a corresponding {@code Locale} instance, or {@code null} if none * @throws IllegalArgumentException in case of an invalid locale specification @@ -868,7 +868,7 @@ public abstract class StringUtils { *

    Note: This delegate does not accept the BCP 47 language tag format. * Please use {@link #parseLocale} for lenient parsing of both formats. * @param localeString the locale {@code String}: following {@code Locale's} - * {@code toString()} format ("en", "en_UK", etc), also accepting spaces as + * {@code toString()} format ("en", "en_UK", etc.), also accepting spaces as * separators (as an alternative to underscores) * @return a corresponding {@code Locale} instance, or {@code null} if none * @throws IllegalArgumentException in case of an invalid locale specification diff --git a/spring-core/src/main/java/org/springframework/util/StringValueResolver.java b/spring-core/src/main/java/org/springframework/util/StringValueResolver.java index 72ba1ec0ca..1335de9586 100644 --- a/spring-core/src/main/java/org/springframework/util/StringValueResolver.java +++ b/spring-core/src/main/java/org/springframework/util/StringValueResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2023 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. @@ -26,7 +26,6 @@ import org.springframework.lang.Nullable; * @since 2.5 * @see org.springframework.beans.factory.config.ConfigurableBeanFactory#resolveAliases * @see org.springframework.beans.factory.config.BeanDefinitionVisitor#BeanDefinitionVisitor(StringValueResolver) - * @see org.springframework.beans.factory.config.PropertyPlaceholderConfigurer */ @FunctionalInterface public interface StringValueResolver { diff --git a/spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java b/spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java index 7c5ac6bdf4..21b58ca18e 100644 --- a/spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java +++ b/spring-core/src/main/java/org/springframework/util/SystemPropertyUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2023 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. @@ -35,13 +35,13 @@ import org.springframework.lang.Nullable; */ public abstract class SystemPropertyUtils { - /** Prefix for system property placeholders: "${". */ + /** Prefix for system property placeholders: {@value}. */ public static final String PLACEHOLDER_PREFIX = "${"; - /** Suffix for system property placeholders: "}". */ + /** Suffix for system property placeholders: {@value}. */ public static final String PLACEHOLDER_SUFFIX = "}"; - /** Value separator for system property placeholders: ":". */ + /** Value separator for system property placeholders: {@value}. */ public static final String VALUE_SEPARATOR = ":"; diff --git a/spring-core/src/main/java/org/springframework/util/UnmodifiableMultiValueMap.java b/spring-core/src/main/java/org/springframework/util/UnmodifiableMultiValueMap.java index 32fdeb1ada..83c8e1f4b6 100644 --- a/spring-core/src/main/java/org/springframework/util/UnmodifiableMultiValueMap.java +++ b/spring-core/src/main/java/org/springframework/util/UnmodifiableMultiValueMap.java @@ -47,7 +47,6 @@ final class UnmodifiableMultiValueMap implements MultiValueMap, Serial private static final long serialVersionUID = -8697084563854098920L; - @SuppressWarnings("serial") private final MultiValueMap delegate; @Nullable @@ -266,7 +265,6 @@ final class UnmodifiableMultiValueMap implements MultiValueMap, Serial private static final long serialVersionUID = 2407578793783925203L; - @SuppressWarnings("serial") private final Set>> delegate; @SuppressWarnings("unchecked") @@ -516,7 +514,6 @@ final class UnmodifiableMultiValueMap implements MultiValueMap, Serial private static final long serialVersionUID = 5518377583904339588L; - @SuppressWarnings("serial") private final Collection> delegate; public UnmodifiableValueCollection(Collection> delegate) { diff --git a/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureAdapter.java b/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureAdapter.java index a05e2436b0..7c12263be3 100644 --- a/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureAdapter.java +++ b/spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 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. @@ -54,7 +54,7 @@ public abstract class ListenableFutureAdapter extends FutureAdapter @Override public void addCallback(final SuccessCallback successCallback, final FailureCallback failureCallback) { ListenableFuture listenableAdaptee = (ListenableFuture) getAdaptee(); - listenableAdaptee.addCallback(new ListenableFutureCallback() { + listenableAdaptee.addCallback(new ListenableFutureCallback<>() { @Override public void onSuccess(@Nullable S result) { T adapted = null; @@ -74,6 +74,7 @@ public abstract class ListenableFutureAdapter extends FutureAdapter } successCallback.onSuccess(adapted); } + @Override public void onFailure(Throwable ex) { failureCallback.onFailure(ex); diff --git a/spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java b/spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java index e6f6cd3d59..aaba75ba29 100644 --- a/spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java +++ b/spring-core/src/main/java/org/springframework/util/xml/TransformerUtils.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 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. @@ -55,7 +55,7 @@ public abstract class TransformerUtils { *

    If the underlying XSLT engine is Xalan, then the special output key {@code indent-amount} * will be also be set to a value of {@link #DEFAULT_INDENT_AMOUNT} characters. * @param transformer the target transformer - * @param indentAmount the size of the indent (2 characters, 3 characters, etc) + * @param indentAmount the size of the indent (2 characters, 3 characters, etc.) * @see javax.xml.transform.Transformer#setOutputProperty(String, String) * @see javax.xml.transform.OutputKeys#INDENT */