|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2018 the original author or authors. |
| 2 | + * Copyright 2002-2019 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
109 | 109 | *
|
110 | 110 | * @author Rossen Stoyanchev
|
111 | 111 | * @author Juergen Hoeller
|
| 112 | + * @author Sam Brannen |
112 | 113 | * @since 3.1
|
113 | 114 | * @see HandlerMethodArgumentResolver
|
114 | 115 | * @see HandlerMethodReturnValueHandler
|
@@ -562,30 +563,34 @@ private void initControllerAdviceCache() {
|
562 | 563 | List<Object> requestResponseBodyAdviceBeans = new ArrayList<Object>();
|
563 | 564 |
|
564 | 565 | for (ControllerAdviceBean bean : beans) {
|
565 |
| - Set<Method> attrMethods = MethodIntrospector.selectMethods(bean.getBeanType(), MODEL_ATTRIBUTE_METHODS); |
| 566 | + Class<?> beanType = bean.getBeanType(); |
| 567 | + |
| 568 | + Set<Method> attrMethods = MethodIntrospector.selectMethods(beanType, MODEL_ATTRIBUTE_METHODS); |
566 | 569 | if (!attrMethods.isEmpty()) {
|
567 | 570 | this.modelAttributeAdviceCache.put(bean, attrMethods);
|
568 | 571 | if (logger.isInfoEnabled()) {
|
569 | 572 | logger.info("Detected @ModelAttribute methods in " + bean);
|
570 | 573 | }
|
571 | 574 | }
|
572 |
| - Set<Method> binderMethods = MethodIntrospector.selectMethods(bean.getBeanType(), INIT_BINDER_METHODS); |
| 575 | + Set<Method> binderMethods = MethodIntrospector.selectMethods(beanType, INIT_BINDER_METHODS); |
573 | 576 | if (!binderMethods.isEmpty()) {
|
574 | 577 | this.initBinderAdviceCache.put(bean, binderMethods);
|
575 | 578 | if (logger.isInfoEnabled()) {
|
576 | 579 | logger.info("Detected @InitBinder methods in " + bean);
|
577 | 580 | }
|
578 | 581 | }
|
579 |
| - if (RequestBodyAdvice.class.isAssignableFrom(bean.getBeanType())) { |
580 |
| - requestResponseBodyAdviceBeans.add(bean); |
581 |
| - if (logger.isInfoEnabled()) { |
582 |
| - logger.info("Detected RequestBodyAdvice bean in " + bean); |
583 |
| - } |
584 |
| - } |
585 |
| - if (ResponseBodyAdvice.class.isAssignableFrom(bean.getBeanType())) { |
| 582 | + |
| 583 | + boolean isRequestBodyAdvice = RequestBodyAdvice.class.isAssignableFrom(beanType); |
| 584 | + boolean isResponseBodyAdvice = ResponseBodyAdvice.class.isAssignableFrom(beanType); |
| 585 | + if (isRequestBodyAdvice || isResponseBodyAdvice) { |
586 | 586 | requestResponseBodyAdviceBeans.add(bean);
|
587 | 587 | if (logger.isInfoEnabled()) {
|
588 |
| - logger.info("Detected ResponseBodyAdvice bean in " + bean); |
| 588 | + if (isRequestBodyAdvice) { |
| 589 | + logger.info("Detected RequestBodyAdvice bean in " + bean); |
| 590 | + } |
| 591 | + else { |
| 592 | + logger.info("Detected ResponseBodyAdvice bean in " + bean); |
| 593 | + } |
589 | 594 | }
|
590 | 595 | }
|
591 | 596 | }
|
|
0 commit comments