@@ -175,46 +175,47 @@ Mono<List<GraphQLError>> resolveException(
175175 Throwable ex , DataFetchingEnvironment environment , @ Nullable Object controller ) {
176176
177177 Object controllerOrAdvice = null ;
178- MethodHolder methodHolder = null ;
178+ MethodReturnValueAdapter methodReturnValueAdapter = null ;
179179 Class <?> controllerType = null ;
180180
181181 if (controller != null ) {
182182 controllerType = ClassUtils .getUserClass (controller .getClass ());
183183 MethodResolver methodResolver = this .controllerCache .get (controllerType );
184184 if (methodResolver != null ) {
185185 controllerOrAdvice = controller ;
186- methodHolder = methodResolver .resolveMethod (ex );
186+ methodReturnValueAdapter = methodResolver .resolveMethod (ex );
187187 }
188188 else if (logger .isWarnEnabled ()) {
189189 logger .warn ("No registration for controller type: " + controllerType .getName ());
190190 }
191191 }
192192
193- if (methodHolder == null ) {
193+ if (methodReturnValueAdapter == null ) {
194194 for (Map .Entry <ControllerAdviceBean , MethodResolver > entry : this .controllerAdviceCache .entrySet ()) {
195195 ControllerAdviceBean advice = entry .getKey ();
196196 if (controller == null || advice .isApplicableToBeanType (controllerType )) {
197- methodHolder = entry .getValue ().resolveMethod (ex );
198- if (methodHolder != null ) {
197+ methodReturnValueAdapter = entry .getValue ().resolveMethod (ex );
198+ if (methodReturnValueAdapter != null ) {
199199 controllerOrAdvice = advice .resolveBean ();
200200 break ;
201201 }
202202 }
203203 }
204204 }
205205
206- if (methodHolder == null ) {
206+ if (methodReturnValueAdapter == null ) {
207207 return Mono .empty ();
208208 }
209209
210- return invokeExceptionHandler (ex , environment , controllerOrAdvice , methodHolder );
210+ return invokeExceptionHandler (ex , environment , controllerOrAdvice , methodReturnValueAdapter );
211211 }
212212
213213 private Mono <List <GraphQLError >> invokeExceptionHandler (
214- Throwable exception , DataFetchingEnvironment env , Object controllerOrAdvice , MethodHolder methodHolder ) {
214+ Throwable exception , DataFetchingEnvironment env , Object controllerOrAdvice ,
215+ MethodReturnValueAdapter methodReturnValueAdapter ) {
215216
216217 DataFetcherHandlerMethod exceptionHandler = new DataFetcherHandlerMethod (
217- new HandlerMethod (controllerOrAdvice , methodHolder .getMethod ()), this .argumentResolvers ,
218+ new HandlerMethod (controllerOrAdvice , methodReturnValueAdapter .getMethod ()), this .argumentResolvers ,
218219 null , null , false );
219220
220221 List <Throwable > exceptions = new ArrayList <>();
@@ -236,7 +237,7 @@ private Mono<List<GraphQLError>> invokeExceptionHandler(
236237
237238 Object result = exceptionHandler .invoke (env , arguments );
238239
239- return methodHolder .adapt (result , exception );
240+ return methodReturnValueAdapter .adapt (result , exception );
240241 }
241242 catch (Throwable invocationEx ) {
242243 // Any other than the original exception (or a cause) is unintended here,
@@ -256,17 +257,17 @@ private Mono<List<GraphQLError>> invokeExceptionHandler(
256257 private static final class MethodResolver {
257258
258259 @ SuppressWarnings ("DataFlowIssue" )
259- private static final MethodHolder NO_MATCH =
260- new MethodHolder (ReflectionUtils .findMethod (MethodResolver .class , "noMatch" ));
260+ private static final MethodReturnValueAdapter NO_MATCH =
261+ new MethodReturnValueAdapter (ReflectionUtils .findMethod (MethodResolver .class , "noMatch" ));
261262
262263
263- private final Map <Class <? extends Throwable >, MethodHolder > exceptionMappings = new HashMap <>(16 );
264+ private final Map <Class <? extends Throwable >, MethodReturnValueAdapter > exceptionMappings = new HashMap <>(16 );
264265
265- private final Map <Class <? extends Throwable >, MethodHolder > resolvedExceptionCache = new ConcurrentReferenceHashMap <>(16 );
266+ private final Map <Class <? extends Throwable >, MethodReturnValueAdapter > resolvedExceptionCache = new ConcurrentReferenceHashMap <>(16 );
266267
267268 MethodResolver (Map <Class <? extends Throwable >, Method > methodMap ) {
268269 methodMap .forEach ((exceptionType , method ) ->
269- this .exceptionMappings .put (exceptionType , new MethodHolder (method )));
270+ this .exceptionMappings .put (exceptionType , new MethodReturnValueAdapter (method )));
270271 }
271272
272273 /**
@@ -276,8 +277,8 @@ private static final class MethodResolver {
276277 * @return the exception handler to use, or {@code null} if no match
277278 */
278279 @ Nullable
279- MethodHolder resolveMethod (Throwable exception ) {
280- MethodHolder method = resolveMethodByExceptionType (exception .getClass ());
280+ MethodReturnValueAdapter resolveMethod (Throwable exception ) {
281+ MethodReturnValueAdapter method = resolveMethodByExceptionType (exception .getClass ());
281282 if (method == null ) {
282283 Throwable cause = exception .getCause ();
283284 if (cause != null ) {
@@ -288,16 +289,16 @@ MethodHolder resolveMethod(Throwable exception) {
288289 }
289290
290291 @ Nullable
291- private MethodHolder resolveMethodByExceptionType (Class <? extends Throwable > exceptionType ) {
292- MethodHolder method = this .resolvedExceptionCache .get (exceptionType );
292+ private MethodReturnValueAdapter resolveMethodByExceptionType (Class <? extends Throwable > exceptionType ) {
293+ MethodReturnValueAdapter method = this .resolvedExceptionCache .get (exceptionType );
293294 if (method == null ) {
294295 method = getMappedMethod (exceptionType );
295296 this .resolvedExceptionCache .put (exceptionType , method );
296297 }
297298 return (method != NO_MATCH ) ? method : null ;
298299 }
299300
300- private MethodHolder getMappedMethod (Class <? extends Throwable > exceptionType ) {
301+ private MethodReturnValueAdapter getMappedMethod (Class <? extends Throwable > exceptionType ) {
301302 List <Class <? extends Throwable >> matches = new ArrayList <>();
302303 for (Class <? extends Throwable > mappedException : this .exceptionMappings .keySet ()) {
303304 if (mappedException .isAssignableFrom (exceptionType )) {
@@ -323,17 +324,17 @@ private void noMatch() {
323324
324325
325326 /**
326- * Container for an exception handler method, and an adapter for its return values .
327+ * Helps to adapt the return value of an exception handler method .
327328 */
328- private static class MethodHolder {
329+ private static class MethodReturnValueAdapter {
329330
330331 private final Method method ;
331332
332333 private final MethodParameter returnType ;
333334
334335 private final ReturnValueAdapter adapter ;
335336
336- MethodHolder (Method method ) {
337+ MethodReturnValueAdapter (Method method ) {
337338 Assert .notNull (method , "Method is required" );
338339 this .method = method ;
339340 this .returnType = new MethodParameter (method , -1 );
0 commit comments