diff --git a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/RSocketServiceMethod.java b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/RSocketServiceMethod.java index 57b4f8daba..29b0c796e9 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/RSocketServiceMethod.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/rsocket/service/RSocketServiceMethod.java @@ -229,7 +229,8 @@ final class RSocketServiceMethod { break; } } - Assert.state(resolved, formatArgumentError(this.parameters[i], "No suitable resolver")); + int index = i; + Assert.state(resolved, () -> formatArgumentError(this.parameters[index], "No suitable resolver")); } } diff --git a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java index 438a82980e..b0095c0028 100644 --- a/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java +++ b/spring-web/src/main/java/org/springframework/web/service/invoker/HttpServiceMethod.java @@ -116,7 +116,8 @@ final class HttpServiceMethod { break; } } - Assert.state(resolved, formatArgumentError(this.parameters[i], "No suitable resolver")); + int index = i; + Assert.state(resolved, () -> formatArgumentError(this.parameters[index], "No suitable resolver")); } }