Skip to content

Commit 3f85a7d

Browse files
committed
Consistent exception naming across InvocableHandlerMethod variants
See gh-22900
1 parent 379d81d commit 3f85a7d

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

spring-messaging/src/main/java/org/springframework/messaging/handler/invocation/InvocableHandlerMethod.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -147,11 +147,11 @@ protected Object[] getMethodArgumentValues(Message<?> message, Object... provide
147147
args[i] = this.resolvers.resolveArgument(parameter, message);
148148
}
149149
catch (Exception ex) {
150-
// Leave stack trace for later, exception may actually be resolved and handled..
150+
// Leave stack trace for later, exception may actually be resolved and handled...
151151
if (logger.isDebugEnabled()) {
152-
String error = ex.getMessage();
153-
if (error != null && !error.contains(parameter.getExecutable().toGenericString())) {
154-
logger.debug(formatArgumentError(parameter, error));
152+
String exMsg = ex.getMessage();
153+
if (exMsg != null && !exMsg.contains(parameter.getExecutable().toGenericString())) {
154+
logger.debug(formatArgumentError(parameter, exMsg));
155155
}
156156
}
157157
throw ex;

spring-web/src/main/java/org/springframework/web/method/support/InvocableHandlerMethod.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -166,11 +166,11 @@ protected Object[] getMethodArgumentValues(NativeWebRequest request, @Nullable M
166166
args[i] = this.resolvers.resolveArgument(parameter, mavContainer, request, this.dataBinderFactory);
167167
}
168168
catch (Exception ex) {
169-
// Leave stack trace for later, exception may actually be resolved and handled..
169+
// Leave stack trace for later, exception may actually be resolved and handled...
170170
if (logger.isDebugEnabled()) {
171-
String error = ex.getMessage();
172-
if (error != null && !error.contains(parameter.getExecutable().toGenericString())) {
173-
logger.debug(formatArgumentError(parameter, error));
171+
String exMsg = ex.getMessage();
172+
if (exMsg != null && !exMsg.contains(parameter.getExecutable().toGenericString())) {
173+
logger.debug(formatArgumentError(parameter, exMsg));
174174
}
175175
}
176176
throw ex;

spring-webflux/src/main/java/org/springframework/web/reactive/result/method/InvocableHandlerMethod.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -190,7 +190,7 @@ private Mono<Object[]> getMethodArgumentValues(
190190
try {
191191
argMonos.add(this.resolvers.resolveArgument(parameter, bindingContext, exchange)
192192
.defaultIfEmpty(NO_ARG_VALUE)
193-
.doOnError(cause -> logArgumentErrorIfNecessary(exchange, parameter, cause)));
193+
.doOnError(ex -> logArgumentErrorIfNecessary(exchange, parameter, ex)));
194194
}
195195
catch (Exception ex) {
196196
logArgumentErrorIfNecessary(exchange, parameter, ex);
@@ -201,14 +201,12 @@ private Mono<Object[]> getMethodArgumentValues(
201201
Stream.of(values).map(o -> o != NO_ARG_VALUE ? o : null).toArray());
202202
}
203203

204-
private void logArgumentErrorIfNecessary(
205-
ServerWebExchange exchange, MethodParameter parameter, Throwable cause) {
206-
207-
// Leave stack trace for later, if error is not handled..
208-
String message = cause.getMessage();
209-
if (!message.contains(parameter.getExecutable().toGenericString())) {
204+
private void logArgumentErrorIfNecessary(ServerWebExchange exchange, MethodParameter parameter, Throwable ex) {
205+
// Leave stack trace for later, if error is not handled...
206+
String exMsg = ex.getMessage();
207+
if (exMsg != null && !exMsg.contains(parameter.getExecutable().toGenericString())) {
210208
if (logger.isDebugEnabled()) {
211-
logger.debug(exchange.getLogPrefix() + formatArgumentError(parameter, message));
209+
logger.debug(exchange.getLogPrefix() + formatArgumentError(parameter, exMsg));
212210
}
213211
}
214212
}

0 commit comments

Comments
 (0)