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 04ad1ac424d..7bb0cc91054 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 @@ -177,7 +177,7 @@ public abstract class DataBufferUtils { if (options.length > 0) { for (OpenOption option : options) { Assert.isTrue(!(option == StandardOpenOption.APPEND || option == StandardOpenOption.WRITE), - "'" + option + "' not allowed"); + () -> "'" + option + "' not allowed"); } } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java index 3c3ff332a97..4ec10611196 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/DefaultRSocketRequesterBuilder.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. @@ -103,7 +103,7 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder { @Override public RSocketRequester.Builder metadataMimeType(MimeType mimeType) { - Assert.notNull(mimeType, "`metadataMimeType` is required"); + Assert.notNull(mimeType, "'metadataMimeType' is required"); this.metadataMimeType = mimeType; return this; } @@ -281,7 +281,7 @@ final class DefaultRSocketRequesterBuilder implements RSocketRequester.Builder { Mono dataMono = Mono.empty(); if (data != null) { ReactiveAdapter adapter = strategies.reactiveAdapterRegistry().getAdapter(data.getClass()); - Assert.isTrue(adapter == null || !adapter.isMultiValue(), "Expected single value: " + data); + Assert.isTrue(adapter == null || !adapter.isMultiValue(), () -> "Expected single value: " + data); Mono mono = (adapter != null ? Mono.from(adapter.toPublisher(data)) : Mono.just(data)); dataMono = mono.map(value -> { ResolvableType type = ResolvableType.forClass(value.getClass()); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java index 24fde3c2d98..30641de0aab 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/MetadataEncoder.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. @@ -141,7 +141,8 @@ final class MetadataEncoder { } ReactiveAdapter adapter = this.strategies.reactiveAdapterRegistry().getAdapter(metadata.getClass()); if (adapter != null) { - Assert.isTrue(!adapter.isMultiValue(), "Expected single value: " + metadata); + Object originalMetadata = metadata; + Assert.isTrue(!adapter.isMultiValue(), () -> "Expected single value: " + originalMetadata); metadata = Mono.from(adapter.toPublisher(metadata)).defaultIfEmpty(NO_VALUE); this.hasAsyncValues = true; } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java index 27fb1a5d76f..5bf5458dd8c 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/annotation/support/RSocketMessageHandler.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. @@ -421,7 +421,7 @@ public class RSocketMessageHandler extends MessageMappingMessageHandler { String str = setupPayload.dataMimeType(); MimeType dataMimeType = StringUtils.hasText(str) ? MimeTypeUtils.parseMimeType(str) : this.defaultDataMimeType; Assert.notNull(dataMimeType, "No `dataMimeType` in ConnectionSetupPayload and no default value"); - Assert.isTrue(isDataMimeTypeSupported(dataMimeType), "Data MimeType '" + dataMimeType + "' not supported"); + Assert.isTrue(isDataMimeTypeSupported(dataMimeType), () -> "Data MimeType '" + dataMimeType + "' not supported"); str = setupPayload.metadataMimeType(); MimeType metaMimeType = StringUtils.hasText(str) ? MimeTypeUtils.parseMimeType(str) : this.defaultMetadataMimeType; diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.java index bd157bd5f80..a2cc4fafee6 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/SimpMessagingTemplate.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. @@ -138,7 +138,7 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate message) { - Assert.notNull(message, "Message is required"); + Assert.notNull(message, "Message must not be null"); String destination = SimpMessageHeaderAccessor.getDestination(message.getHeaders()); if (destination != null) { sendInternal(message); @@ -224,7 +224,8 @@ public class SimpMessagingTemplate extends AbstractMessageSendingTemplate "Invalid sequence \"%2F\" in user name: " + username); user = StringUtils.replace(user, "/", "%2F"); destination = destination.startsWith("/") ? destination : "/" + destination; super.convertAndSend(this.destinationPrefix + user + destination, payload, headers, postProcessor); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/OrderedMessageChannelDecorator.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/OrderedMessageChannelDecorator.java index f4312910dc2..939de194ce1 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/OrderedMessageChannelDecorator.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/broker/OrderedMessageChannelDecorator.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. @@ -148,7 +148,7 @@ public class OrderedMessageChannelDecorator implements MessageChannel { public static void configureInterceptor(MessageChannel channel, boolean preserveOrder) { if (preserveOrder) { Assert.isInstanceOf(ExecutorSubscribableChannel.class, channel, - "An ExecutorSubscribableChannel is required for `preservePublishOrder`"); + "An ExecutorSubscribableChannel is required for 'preservePublishOrder'"); ExecutorSubscribableChannel execChannel = (ExecutorSubscribableChannel) channel; if (execChannel.getInterceptors().stream().noneMatch(i -> i instanceof CallbackInterceptor)) { execChannel.addInterceptor(0, new CallbackInterceptor()); diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java index ea38f8f85f5..00e524582d7 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompHeaders.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. @@ -211,7 +211,7 @@ public class StompHeaders implements MultiValueMap, Serializable } Arrays.stream(acceptVersions).forEach(version -> Assert.isTrue(version != null && (version.equals("1.1") || version.equals("1.2")), - "Invalid version: " + version)); + () -> "Invalid version: " + version)); set(ACCEPT_VERSION, StringUtils.arrayToCommaDelimitedString(acceptVersions)); } diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java index 62729df07e9..3697afce407 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/user/DefaultUserDestinationResolver.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. @@ -203,7 +203,7 @@ public class DefaultUserDestinationResolver implements UserDestinationResolver { } Principal principal = SimpMessageHeaderAccessor.getUser(headers); String user = (principal != null ? principal.getName() : null); - Assert.isTrue(user == null || !user.contains("%2F"), "Invalid sequence \"%2F\" in user name: " + user); + Assert.isTrue(user == null || !user.contains("%2F"), () -> "Invalid sequence \"%2F\" in user name: " + user); Set sessionIds = Collections.singleton(sessionId); return new ParseResult(sourceDestination, actualDestination, sourceDestination, sessionIds, user); } diff --git a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java index f403ad91384..06c0cb11d75 100644 --- a/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/reactive/server/DefaultWebTestClientBuilder.java @@ -230,7 +230,7 @@ class DefaultWebTestClientBuilder implements WebTestClient.Builder { @Override public WebTestClient.Builder entityExchangeResultConsumer(Consumer> entityResultConsumer) { - Assert.notNull(entityResultConsumer, "`entityResultConsumer` is required"); + Assert.notNull(entityResultConsumer, "'entityResultConsumer' is required"); this.entityResultConsumer = this.entityResultConsumer.andThen(entityResultConsumer); return this; } diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java index 6bfe5d5ceae..bfd339a51cb 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/request/MockHttpServletRequestBuilder.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. @@ -148,8 +148,8 @@ public class MockHttpServletRequestBuilder private static URI initUri(String url, Object[] vars) { Assert.notNull(url, "'url' must not be null"); - Assert.isTrue(url.startsWith("/") || url.startsWith("http://") || url.startsWith("https://"), "" + - "'url' should start with a path or be a complete HTTP URL: " + url); + Assert.isTrue(url.startsWith("/") || url.startsWith("http://") || url.startsWith("https://"), + () -> "'url' should start with a path or be a complete HTTP URL: " + url); return UriComponentsBuilder.fromUriString(url).buildAndExpand(vars).encode().toUri(); } diff --git a/spring-test/src/test/java/org/springframework/test/context/junit4/hybrid/HybridContextLoader.java b/spring-test/src/test/java/org/springframework/test/context/junit4/hybrid/HybridContextLoader.java index 7e56b4fa9e0..9f8c06534ca 100644 --- a/spring-test/src/test/java/org/springframework/test/context/junit4/hybrid/HybridContextLoader.java +++ b/spring-test/src/test/java/org/springframework/test/context/junit4/hybrid/HybridContextLoader.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. @@ -42,8 +42,8 @@ public class HybridContextLoader extends AbstractGenericContextLoader { @Override protected void validateMergedContextConfiguration(MergedContextConfiguration mergedConfig) { - Assert.isTrue(mergedConfig.hasClasses() || mergedConfig.hasLocations(), getClass().getSimpleName() - + " requires either classes or locations"); + Assert.isTrue(mergedConfig.hasResources(), + () -> getClass().getSimpleName() + " requires either classes or locations"); } @Override 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 ae3dcf606c9..f9c3a97eff4 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.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. @@ -465,7 +465,7 @@ public final class ContentDisposition { * @see RFC 5987 */ private static String decodeFilename(String filename, Charset charset) { - Assert.notNull(filename, "'input' String` should not be null"); + Assert.notNull(filename, "'input' String should not be null"); Assert.notNull(charset, "'charset' should not be null"); byte[] value = filename.getBytes(charset); ByteArrayOutputStream baos = new ByteArrayOutputStream(); @@ -531,10 +531,10 @@ public final class ContentDisposition { * @see RFC 5987 */ private static String encodeFilename(String input, Charset charset) { - Assert.notNull(input, "`input` is required"); - Assert.notNull(charset, "`charset` is required"); + Assert.notNull(input, "'input' is required"); + Assert.notNull(charset, "'charset' is required"); Assert.isTrue(!StandardCharsets.US_ASCII.equals(charset), "ASCII does not require encoding"); - Assert.isTrue(UTF_8.equals(charset) || ISO_8859_1.equals(charset), "Only UTF-8 and ISO-8859-1 supported."); + Assert.isTrue(UTF_8.equals(charset) || ISO_8859_1.equals(charset), "Only UTF-8 and ISO-8859-1 are supported"); byte[] source = input.getBytes(charset); int len = source.length; StringBuilder sb = new StringBuilder(len << 1); diff --git a/spring-web/src/main/java/org/springframework/http/HttpRange.java b/spring-web/src/main/java/org/springframework/http/HttpRange.java index ae591cd3352..3526b15cb87 100644 --- a/spring-web/src/main/java/org/springframework/http/HttpRange.java +++ b/spring-web/src/main/java/org/springframework/http/HttpRange.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. @@ -65,7 +65,7 @@ public abstract class HttpRange { long contentLength = getLengthFor(resource); long start = getRangeStart(contentLength); long end = getRangeEnd(contentLength); - Assert.isTrue(start < contentLength, "'position' exceeds the resource length " + contentLength); + Assert.isTrue(start < contentLength, () -> "'position' exceeds the resource length " + contentLength); return new ResourceRegion(resource, start, end - start + 1); } diff --git a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java index 57107e5270d..538c2e41a86 100644 --- a/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java +++ b/spring-web/src/main/java/org/springframework/http/codec/json/Jackson2CodecSupport.java @@ -231,7 +231,7 @@ public abstract class Jackson2CodecSupport { JsonView annotation = getAnnotation(param, JsonView.class); if (annotation != null) { Class[] classes = annotation.value(); - Assert.isTrue(classes.length == 1, JSON_VIEW_HINT_ERROR + param); + Assert.isTrue(classes.length == 1, () -> JSON_VIEW_HINT_ERROR + param); hints = (hints != null ? hints : new HashMap<>(1)); hints.put(JSON_VIEW_HINT, classes[0]); } diff --git a/spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java index 62a899f9b3a..3aaff775405 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/BufferedImageHttpMessageConverter.java @@ -128,7 +128,7 @@ public class BufferedImageHttpMessageConverter implements HttpMessageConverter "'cacheDir' is not a directory: " + cacheDir); this.cacheDir = cacheDir; } diff --git a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java index 8458ba1d651..105e94b86ba 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/FormHttpMessageConverter.java @@ -436,7 +436,7 @@ public class FormHttpMessageConverter implements HttpMessageConverter { if (name == null) { - Assert.isTrue(CollectionUtils.isEmpty(values), "Null name in form data: " + formData); + Assert.isTrue(CollectionUtils.isEmpty(values), () -> "Null name in form data: " + formData); return; } values.forEach(value -> { diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.java b/spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.java index d4398d76091..2c1716c9902 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/DefaultServerHttpRequestBuilder.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. @@ -93,7 +93,7 @@ class DefaultServerHttpRequestBuilder implements ServerHttpRequest.Builder { @Override public ServerHttpRequest.Builder path(String path) { - Assert.isTrue(path.startsWith("/"), "The path does not have a leading slash."); + Assert.isTrue(path.startsWith("/"), () -> "The path does not have a leading slash: " + path); this.uriPath = path; return this; } diff --git a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java index 51fa59839af..4a86019c74e 100644 --- a/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java +++ b/spring-web/src/main/java/org/springframework/http/server/reactive/ServletServerHttpRequest.java @@ -90,7 +90,7 @@ class ServletServerHttpRequest extends AbstractServerHttpRequest { super(initUri(request), request.getContextPath() + servletPath, initHeaders(headers, request)); Assert.notNull(bufferFactory, "'bufferFactory' must not be null"); - Assert.isTrue(bufferSize > 0, "'bufferSize' must be higher than 0"); + Assert.isTrue(bufferSize > 0, "'bufferSize' must be greater than 0"); this.request = request; this.bufferFactory = bufferFactory; diff --git a/spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java b/spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java index 271193cc638..cf49fc8daa8 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/AbstractRequestLoggingFilter.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. @@ -209,7 +209,7 @@ public abstract class AbstractRequestLoggingFilter extends OncePerRequestFilter * @since 3.0 */ public void setMaxPayloadLength(int maxPayloadLength) { - Assert.isTrue(maxPayloadLength >= 0, "'maxPayloadLength' should be larger than or equal to 0"); + Assert.isTrue(maxPayloadLength >= 0, "'maxPayloadLength' must be greater than or equal to 0"); this.maxPayloadLength = maxPayloadLength; } diff --git a/spring-web/src/main/java/org/springframework/web/filter/RelativeRedirectFilter.java b/spring-web/src/main/java/org/springframework/web/filter/RelativeRedirectFilter.java index 25df286a0c4..bc8ec87d0de 100644 --- a/spring-web/src/main/java/org/springframework/web/filter/RelativeRedirectFilter.java +++ b/spring-web/src/main/java/org/springframework/web/filter/RelativeRedirectFilter.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. @@ -53,7 +53,7 @@ public class RelativeRedirectFilter extends OncePerRequestFilter { */ public void setRedirectStatus(HttpStatus status) { Assert.notNull(status, "Property 'redirectStatus' is required"); - Assert.isTrue(status.is3xxRedirection(), "Not a redirect status code"); + Assert.isTrue(status.is3xxRedirection(), () -> "Not a redirect status code: " + status); this.redirectStatus = status; } diff --git a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java index ac43d5394c9..1c81fbc9971 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java +++ b/spring-web/src/main/java/org/springframework/web/util/UrlPathHelper.java @@ -205,12 +205,12 @@ public class UrlPathHelper { * Return a previously {@link #getLookupPathForRequest resolved} lookupPath. * @param request the current request * @return the previously resolved lookupPath - * @throws IllegalArgumentException if the not found + * @throws IllegalArgumentException if the lookup path is not found * @since 5.3 */ public static String getResolvedLookupPath(ServletRequest request) { String lookupPath = (String) request.getAttribute(PATH_ATTRIBUTE); - Assert.notNull(lookupPath, "Expected lookupPath in request attribute \"" + PATH_ATTRIBUTE + "\"."); + Assert.notNull(lookupPath, () -> "Expected lookupPath in request attribute \"" + PATH_ATTRIBUTE + "\"."); return lookupPath; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/CompositeRequestCondition.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/CompositeRequestCondition.java index afaf28433e7..d9eca32157e 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/CompositeRequestCondition.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/condition/CompositeRequestCondition.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. @@ -31,8 +31,8 @@ import org.springframework.web.server.ServerWebExchange; * ensure all conditions match a given request. * *

When {@code CompositeRequestCondition} instances are combined or compared - * they are expected to (a) contain the same number of conditions and (b) that - * conditions in the respective index are of the same type. It is acceptable to + * is expected that (a) they contain the same number of conditions and (b) + * conditions at the same index are of the same type. It is acceptable to * provide {@code null} conditions or no conditions at all to the constructor. * * @author Rossen Stoyanchev @@ -105,7 +105,7 @@ public class CompositeRequestCondition extends AbstractRequestConditionIf both instances have conditions, combine the individual conditions * after ensuring they are of the same type and number. */ @Override @@ -131,8 +131,8 @@ public class CompositeRequestCondition extends AbstractRequestCondition "Cannot combine CompositeRequestConditions with a different number of conditions. " + + ObjectUtils.nullSafeToString(this.requestConditions) + " and " + ObjectUtils.nullSafeToString(other.requestConditions)); } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java index ed9b89c8fc8..de9578d77e4 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/result/view/RedirectView.java @@ -97,7 +97,7 @@ public class RedirectView extends AbstractUrlBasedView { * {@link HttpStatus#PERMANENT_REDIRECT}. */ public void setStatusCode(HttpStatus statusCode) { - Assert.isTrue(statusCode.is3xxRedirection(), "Not a redirect status code"); + Assert.isTrue(statusCode.is3xxRedirection(), () -> "Not a redirect status code: " + statusCode); this.statusCode = statusCode; } diff --git a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java index 304eb797d79..5a7aa5e17d4 100644 --- a/spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.java +++ b/spring-webflux/src/main/java/org/springframework/web/reactive/socket/CloseStatus.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. @@ -154,7 +154,7 @@ public final class CloseStatus { * @param reason the reason */ public CloseStatus(int code, @Nullable String reason) { - Assert.isTrue((code >= 1000 && code < 5000), "Invalid status code"); + Assert.isTrue((code >= 1000 && code < 5000), () -> "Invalid status code: " + code); this.code = code; this.reason = reason; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java index fb015a7c576..b48cd7571b3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/RedirectViewControllerRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 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. @@ -54,7 +54,7 @@ public class RedirectViewControllerRegistration { * will select {@code HttpStatus.MOVED_TEMPORARILY (302)} by default. */ public RedirectViewControllerRegistration setStatusCode(HttpStatus statusCode) { - Assert.isTrue(statusCode.is3xxRedirection(), "Not a redirect status code"); + Assert.isTrue(statusCode.is3xxRedirection(), () -> "Not a redirect status code: " + statusCode); this.redirectView.setStatusCode(statusCode); return this; } diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/CompositeRequestCondition.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/CompositeRequestCondition.java index d2bf8da0ac2..23bacd18be3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/CompositeRequestCondition.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/condition/CompositeRequestCondition.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. @@ -133,8 +133,8 @@ public class CompositeRequestCondition extends AbstractRequestCondition "Cannot combine CompositeRequestConditions with a different number of conditions. " + + ObjectUtils.nullSafeToString(this.requestConditions) + " and " + ObjectUtils.nullSafeToString(other.requestConditions)); } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/CloseStatus.java b/spring-websocket/src/main/java/org/springframework/web/socket/CloseStatus.java index 66b084bd77b..e2f6b46114e 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/CloseStatus.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/CloseStatus.java @@ -168,7 +168,7 @@ public final class CloseStatus implements Serializable { * @param reason the reason */ public CloseStatus(int code, @Nullable String reason) { - Assert.isTrue((code >= 1000 && code < 5000), "Invalid status code"); + Assert.isTrue((code >= 1000 && code < 5000), () -> "Invalid status code: " + code); this.code = code; this.reason = reason; }