diff --git a/build.gradle b/build.gradle index 57da10ebc9..03c0c306c8 100644 --- a/build.gradle +++ b/build.gradle @@ -167,4 +167,4 @@ configure(rootProject) { maxHeapSize = "1g" } -} +} diff --git a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java index 52f8bae918..39a459e915 100644 --- a/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java +++ b/spring-core/src/main/java/org/springframework/core/io/buffer/DataBufferUtils.java @@ -712,7 +712,7 @@ public abstract class DataBufferUtils { @Override public byte[] delimiter() { - Assert.state(this.longestDelimiter != NO_DELIMITER, "Illegal state!"); + Assert.state(this.longestDelimiter != NO_DELIMITER, "'delimiter' not set"); return this.longestDelimiter; } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java index 2094a8c502..1b46f878b9 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/support/MessageHeaderAccessor.java @@ -43,7 +43,7 @@ import org.springframework.util.StringUtils; * strongly typed accessors for specific headers, the ability to leave headers * in a {@link Message} mutable, and the option to suppress automatic generation * of {@link MessageHeaders#ID id} and {@link MessageHeaders#TIMESTAMP - * timesteamp} headers. Subclasses such as {@link NativeMessageHeaderAccessor} + * timestamp} headers. Subclasses such as {@link NativeMessageHeaderAccessor} * and others provide support for managing processing vs external source headers * as well as protocol specific headers. * diff --git a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java index 26e476fd71..13b9e1be18 100644 --- a/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java +++ b/spring-r2dbc/src/main/java/org/springframework/r2dbc/core/DefaultDatabaseClient.java @@ -282,7 +282,7 @@ class DefaultDatabaseClient implements DatabaseClient { public DefaultGenericExecuteSpec bind(String name, Object value) { assertNotPreparedOperation(); - Assert.hasText(name, "Parameter name must not be null or empty!"); + Assert.hasText(name, "Parameter name must not be null or empty"); Assert.notNull(value, () -> String.format( "Value for parameter %s must not be null. Use bindNull(…) instead.", name)); @@ -303,7 +303,7 @@ class DefaultDatabaseClient implements DatabaseClient { @Override public DefaultGenericExecuteSpec bindNull(String name, Class type) { assertNotPreparedOperation(); - Assert.hasText(name, "Parameter name must not be null or empty!"); + Assert.hasText(name, "Parameter name must not be null or empty"); Map byName = new LinkedHashMap<>(this.byName); byName.put(name, Parameters.in(type)); @@ -313,7 +313,7 @@ class DefaultDatabaseClient implements DatabaseClient { @Override public DefaultGenericExecuteSpec filter(StatementFilterFunction filter) { - Assert.notNull(filter, "Statement FilterFunction must not be null"); + Assert.notNull(filter, "StatementFilterFunction must not be null"); return new DefaultGenericExecuteSpec( this.byIndex, this.byName, this.sqlSupplier, this.filterFunction.andThen(filter)); } @@ -471,7 +471,7 @@ class DefaultDatabaseClient implements DatabaseClient { private String getRequiredSql(Supplier sqlSupplier) { String sql = sqlSupplier.get(); - Assert.state(StringUtils.hasText(sql), "SQL returned by SQL supplier must not be empty!"); + Assert.state(StringUtils.hasText(sql), "SQL returned by supplier must not be empty"); return sql; } diff --git a/spring-test/src/main/java/org/springframework/mock/web/PassThroughFilterChain.java b/spring-test/src/main/java/org/springframework/mock/web/PassThroughFilterChain.java index 03fbfac105..faee6f8258 100644 --- a/spring-test/src/main/java/org/springframework/mock/web/PassThroughFilterChain.java +++ b/spring-test/src/main/java/org/springframework/mock/web/PassThroughFilterChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 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. @@ -84,7 +84,7 @@ public class PassThroughFilterChain implements FilterChain { this.filter.doFilter(request, response, this.nextFilterChain); } else { - Assert.state(this.servlet != null, "Neither a Filter not a Servlet set"); + Assert.state(this.servlet != null, "Neither a Filter nor a Servlet has been set"); this.servlet.service(request, response); } } diff --git a/spring-web/src/main/java/org/springframework/http/MediaType.java b/spring-web/src/main/java/org/springframework/http/MediaType.java index 5a4a6a55cf..7ae2229f1d 100644 --- a/spring-web/src/main/java/org/springframework/http/MediaType.java +++ b/spring-web/src/main/java/org/springframework/http/MediaType.java @@ -544,10 +544,10 @@ public class MediaType extends MimeType implements Serializable { protected void checkParameters(String parameter, String value) { super.checkParameters(parameter, value); if (PARAM_QUALITY_FACTOR.equals(parameter)) { - value = unquote(value); - double d = Double.parseDouble(value); + String unquotedValue = unquote(value); + double d = Double.parseDouble(unquotedValue); Assert.isTrue(d >= 0D && d <= 1D, - "Invalid quality value \"" + value + "\": should be between 0.0 and 1.0"); + () -> "Invalid quality value \"" + value + "\": should be between 0.0 and 1.0"); } } diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java index e47f96deba..136f660140 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java @@ -369,7 +369,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener Charset charset = getCharset(contentType); ObjectMapper objectMapper = selectObjectMapper(javaType.getRawClass(), contentType); - Assert.state(objectMapper != null, "No ObjectMapper for " + javaType); + Assert.state(objectMapper != null, () -> "No ObjectMapper for " + javaType); boolean isUnicode = ENCODINGS.containsKey(charset.name()) || "UTF-16".equals(charset.name()) || @@ -448,7 +448,7 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener Class clazz = (object instanceof MappingJacksonValue mappingJacksonValue ? mappingJacksonValue.getValue().getClass() : object.getClass()); ObjectMapper objectMapper = selectObjectMapper(clazz, contentType); - Assert.state(objectMapper != null, "No ObjectMapper for " + clazz.getName()); + Assert.state(objectMapper != null, () -> "No ObjectMapper for " + clazz.getName()); OutputStream outputStream = StreamUtils.nonClosing(outputMessage.getBody()); try (JsonGenerator generator = objectMapper.getFactory().createGenerator(outputStream, encoding)) { diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java index 9b7e1c4846..a7025ae34d 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -195,7 +195,7 @@ public final class WebAsyncManager { */ public void registerCallableInterceptor(Object key, CallableProcessingInterceptor interceptor) { Assert.notNull(key, "Key is required"); - Assert.notNull(interceptor, "CallableProcessingInterceptor is required"); + Assert.notNull(interceptor, "CallableProcessingInterceptor is required"); this.callableInterceptors.put(key, interceptor); } diff --git a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/PassThroughFilterChain.java b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/PassThroughFilterChain.java index 2100b0421b..3f88087689 100644 --- a/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/PassThroughFilterChain.java +++ b/spring-web/src/testFixtures/java/org/springframework/web/testfixture/servlet/PassThroughFilterChain.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2022 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. @@ -84,7 +84,7 @@ public class PassThroughFilterChain implements FilterChain { this.filter.doFilter(request, response, this.nextFilterChain); } else { - Assert.state(this.servlet != null, "Neither a Filter not a Servlet set"); + Assert.state(this.servlet != null, "Neither a Filter nor a Servlet has been set"); this.servlet.service(request, response); } } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/script/ScriptTemplateView.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/script/ScriptTemplateView.java index b831397518..415b126475 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/script/ScriptTemplateView.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/script/ScriptTemplateView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2022 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. @@ -227,12 +227,12 @@ public class ScriptTemplateView extends AbstractUrlBasedView { engineCount++; } Assert.isTrue(engineCount == 1, - "You should define either 'engine', 'engineSupplier' or 'engineName'."); + "You should define either 'engine', 'engineSupplier', or 'engineName'."); if (Boolean.FALSE.equals(this.sharedEngine)) { Assert.isTrue(this.engine == null, "When 'sharedEngine' is set to false, you should specify the " + - "script engine using 'engineName' or 'engineSupplier' , not 'engine'."); + "script engine using 'engineName' or 'engineSupplier', not 'engine'."); } else if (this.engine != null) { loadScripts(this.engine); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java index 2c087975af..e0f4fb5a8c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/MvcUriComponentsBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -448,7 +448,7 @@ public class MvcUriComponentsBuilder { */ public static MethodArgumentBuilder fromMappingName(@Nullable UriComponentsBuilder builder, String name) { WebApplicationContext wac = getWebApplicationContext(); - Assert.notNull(wac, "No WebApplicationContext. "); + Assert.notNull(wac, "No WebApplicationContext"); Map map = wac.getBeansOfType(RequestMappingInfoHandlerMapping.class); List handlerMethods = null; for (RequestMappingInfoHandlerMapping mapping : map.values()) { diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java index 732a677933..929385ba68 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ResponseBodyEmitter.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -193,8 +193,7 @@ public class ResponseBodyEmitter { * @throws java.lang.IllegalStateException wraps any other errors */ public synchronized void send(Object object, @Nullable MediaType mediaType) throws IOException { - Assert.state(!this.complete, - "ResponseBodyEmitter has already completed" + + Assert.state(!this.complete, () -> "ResponseBodyEmitter has already completed" + (this.failure != null ? " with error: " + this.failure : "")); sendInternal(object, mediaType); } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBody.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBody.java index eb307b4a62..3c6fe1575c 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBody.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/StreamingResponseBody.java @@ -16,7 +16,6 @@ package org.springframework.web.servlet.mvc.method.annotation; - import java.io.IOException; import java.io.OutputStream; diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java index f7626a9deb..7b51b72861 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/view/script/ScriptTemplateView.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 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. @@ -259,12 +259,12 @@ public class ScriptTemplateView extends AbstractUrlBasedView { engineCount++; } Assert.isTrue(engineCount == 1, - "You should define either 'engine', 'engineSupplier' or 'engineName'."); + "You should define either 'engine', 'engineSupplier', or 'engineName'."); if (Boolean.FALSE.equals(this.sharedEngine)) { Assert.isTrue(this.engine == null, "When 'sharedEngine' is set to false, you should specify the " + - "script engine using 'engineName' or 'engineSupplier' , not 'engine'."); + "script engine using 'engineName' or 'engineSupplier', not 'engine'."); } else if (this.engine != null) { loadScripts(this.engine);