@@ -176,46 +176,47 @@ public Mono<List<GraphQLError>> resolveException(
176176 Throwable ex , DataFetchingEnvironment environment , @ Nullable Object controller ) {
177177
178178 Object controllerOrAdvice = null ;
179- MethodHolder methodHolder = null ;
179+ MethodReturnValueAdapter methodReturnValueAdapter = null ;
180180 Class <?> controllerType = null ;
181181
182182 if (controller != null ) {
183183 controllerType = ClassUtils .getUserClass (controller .getClass ());
184184 MethodResolver methodResolver = this .controllerCache .get (controllerType );
185185 if (methodResolver != null ) {
186186 controllerOrAdvice = controller ;
187- methodHolder = methodResolver .resolveMethod (ex );
187+ methodReturnValueAdapter = methodResolver .resolveMethod (ex );
188188 }
189189 else if (logger .isWarnEnabled ()) {
190190 logger .warn ("No registration for controller type: " + controllerType .getName ());
191191 }
192192 }
193193
194- if (methodHolder == null ) {
194+ if (methodReturnValueAdapter == null ) {
195195 for (Map .Entry <ControllerAdviceBean , MethodResolver > entry : this .controllerAdviceCache .entrySet ()) {
196196 ControllerAdviceBean advice = entry .getKey ();
197197 if (controller == null || advice .isApplicableToBeanType (controllerType )) {
198- methodHolder = entry .getValue ().resolveMethod (ex );
199- if (methodHolder != null ) {
198+ methodReturnValueAdapter = entry .getValue ().resolveMethod (ex );
199+ if (methodReturnValueAdapter != null ) {
200200 controllerOrAdvice = advice .resolveBean ();
201201 break ;
202202 }
203203 }
204204 }
205205 }
206206
207- if (methodHolder == null ) {
207+ if (methodReturnValueAdapter == null ) {
208208 return Mono .empty ();
209209 }
210210
211- return invokeExceptionHandler (ex , environment , controllerOrAdvice , methodHolder );
211+ return invokeExceptionHandler (ex , environment , controllerOrAdvice , methodReturnValueAdapter );
212212 }
213213
214214 private Mono <List <GraphQLError >> invokeExceptionHandler (
215- Throwable exception , DataFetchingEnvironment env , Object controllerOrAdvice , MethodHolder methodHolder ) {
215+ Throwable exception , DataFetchingEnvironment env , Object controllerOrAdvice ,
216+ MethodReturnValueAdapter methodReturnValueAdapter ) {
216217
217218 DataFetcherHandlerMethod exceptionHandler = new DataFetcherHandlerMethod (
218- new HandlerMethod (controllerOrAdvice , methodHolder .getMethod ()), this .argumentResolvers ,
219+ new HandlerMethod (controllerOrAdvice , methodReturnValueAdapter .getMethod ()), this .argumentResolvers ,
219220 null , null , false , false );
220221
221222 List <Throwable > exceptions = new ArrayList <>();
@@ -237,7 +238,7 @@ private Mono<List<GraphQLError>> invokeExceptionHandler(
237238
238239 Object result = exceptionHandler .invoke (env , arguments );
239240
240- return methodHolder .adapt (result , exception );
241+ return methodReturnValueAdapter .adapt (result , exception );
241242 }
242243 catch (Throwable invocationEx ) {
243244 // Any other than the original exception (or a cause) is unintended here,
@@ -257,17 +258,17 @@ private Mono<List<GraphQLError>> invokeExceptionHandler(
257258 private static final class MethodResolver {
258259
259260 @ SuppressWarnings ("DataFlowIssue" )
260- private static final MethodHolder NO_MATCH =
261- new MethodHolder (ReflectionUtils .findMethod (MethodResolver .class , "noMatch" ));
261+ private static final MethodReturnValueAdapter NO_MATCH =
262+ new MethodReturnValueAdapter (ReflectionUtils .findMethod (MethodResolver .class , "noMatch" ));
262263
263264
264- private final Map <Class <? extends Throwable >, MethodHolder > exceptionMappings = new HashMap <>(16 );
265+ private final Map <Class <? extends Throwable >, MethodReturnValueAdapter > exceptionMappings = new HashMap <>(16 );
265266
266- private final Map <Class <? extends Throwable >, MethodHolder > resolvedExceptionCache = new ConcurrentReferenceHashMap <>(16 );
267+ private final Map <Class <? extends Throwable >, MethodReturnValueAdapter > resolvedExceptionCache = new ConcurrentReferenceHashMap <>(16 );
267268
268269 MethodResolver (Map <Class <? extends Throwable >, Method > methodMap ) {
269270 methodMap .forEach ((exceptionType , method ) ->
270- this .exceptionMappings .put (exceptionType , new MethodHolder (method )));
271+ this .exceptionMappings .put (exceptionType , new MethodReturnValueAdapter (method )));
271272 }
272273
273274 /**
@@ -277,8 +278,8 @@ private static final class MethodResolver {
277278 * @return the exception handler to use, or {@code null} if no match
278279 */
279280 @ Nullable
280- MethodHolder resolveMethod (Throwable exception ) {
281- MethodHolder method = resolveMethodByExceptionType (exception .getClass ());
281+ MethodReturnValueAdapter resolveMethod (Throwable exception ) {
282+ MethodReturnValueAdapter method = resolveMethodByExceptionType (exception .getClass ());
282283 if (method == null ) {
283284 Throwable cause = exception .getCause ();
284285 if (cause != null ) {
@@ -289,16 +290,16 @@ MethodHolder resolveMethod(Throwable exception) {
289290 }
290291
291292 @ Nullable
292- private MethodHolder resolveMethodByExceptionType (Class <? extends Throwable > exceptionType ) {
293- MethodHolder method = this .resolvedExceptionCache .get (exceptionType );
293+ private MethodReturnValueAdapter resolveMethodByExceptionType (Class <? extends Throwable > exceptionType ) {
294+ MethodReturnValueAdapter method = this .resolvedExceptionCache .get (exceptionType );
294295 if (method == null ) {
295296 method = getMappedMethod (exceptionType );
296297 this .resolvedExceptionCache .put (exceptionType , method );
297298 }
298299 return (method != NO_MATCH ) ? method : null ;
299300 }
300301
301- private MethodHolder getMappedMethod (Class <? extends Throwable > exceptionType ) {
302+ private MethodReturnValueAdapter getMappedMethod (Class <? extends Throwable > exceptionType ) {
302303 List <Class <? extends Throwable >> matches = new ArrayList <>();
303304 for (Class <? extends Throwable > mappedException : this .exceptionMappings .keySet ()) {
304305 if (mappedException .isAssignableFrom (exceptionType )) {
@@ -324,17 +325,17 @@ private void noMatch() {
324325
325326
326327 /**
327- * Container for an exception handler method, and an adapter for its return values .
328+ * Helps to adapt the return value of an exception handler method .
328329 */
329- private static class MethodHolder {
330+ private static class MethodReturnValueAdapter {
330331
331332 private final Method method ;
332333
333334 private final MethodParameter returnType ;
334335
335336 private final ReturnValueAdapter adapter ;
336337
337- MethodHolder (Method method ) {
338+ MethodReturnValueAdapter (Method method ) {
338339 Assert .notNull (method , "Method is required" );
339340 this .method = method ;
340341 this .returnType = new MethodParameter (method , -1 );
0 commit comments