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 39a459e9152..8ad237c7f3a 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 c251b7dbcd1..37770068873 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-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. @@ -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 da667cc7c96..3e54088ccb5 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-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. @@ -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 d8f55c762b4..0638e2f4f8b 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-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,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 e119e08215f..f39b7ad9ace 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. @@ -212,7 +212,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 86e59e73c25..b7b07a73190 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-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. @@ -179,7 +179,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 a55c6584714..31b3d6c37d4 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 @@ -234,7 +234,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 f4efb38abb7..32333995faf 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 @@ -148,7 +148,7 @@ public class MockHttpServletRequestBuilder private static URI initUri(String url, Object[] vars) { Assert.notNull(url, "'url' must not be null"); Assert.isTrue(url.isEmpty() || url.startsWith("/") || url.startsWith("http://") || url.startsWith("https://"), - "'url' should start with a path or be a complete HTTP URL: " + url); + () -> "'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 eb5cd931674..0da712c16cc 100644 --- a/spring-web/src/main/java/org/springframework/http/ContentDisposition.java +++ b/spring-web/src/main/java/org/springframework/http/ContentDisposition.java @@ -492,7 +492,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(); @@ -603,10 +603,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 25159745e57..262639307b7 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-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. @@ -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 7d4329f7390..26e87e371a4 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 @@ -242,7 +242,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 47bc0336f62..4e0a8ff1822 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 ed430a56232..87f576988c9 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 @@ -432,7 +432,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 f3e4ba62b74..282bdc364da 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. @@ -94,7 +94,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 f47d58f2647..e010c1bdad4 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 a91fbc2b16f..190666c12af 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 d1f204e0501..a30337aaee8 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. @@ -54,7 +54,7 @@ public class RelativeRedirectFilter extends OncePerRequestFilter { */ public void setRedirectStatus(HttpStatusCode 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 419f6ac4294..4a7a3b70128 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 @@ -200,12 +200,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 02108639eab..d004cf558b8 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 @@ -98,7 +98,7 @@ public class RedirectView extends AbstractUrlBasedView { * {@link HttpStatus#PERMANENT_REDIRECT}. */ public void setStatusCode(HttpStatusCode 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 603f2ba1656..808d0b290dc 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-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. @@ -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 876956dd713..45621534c95 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(HttpStatusCode 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 62eac8bb5d2..aaa8d5f0407 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 bf68fcefe54..77d7465982b 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; }