@@ -398,7 +398,9 @@ private MessagingMethodInvokerHelper(Object targetObject, Class<? extends Annota
398
398
}
399
399
400
400
private boolean isProvidedMessageHandlerFactoryBean () {
401
- return getBeanFactory ().containsBean (IntegrationContextUtils .MESSAGE_HANDLER_FACTORY_BEAN_NAME );
401
+ BeanFactory beanFactory = getBeanFactory ();
402
+ return beanFactory != null
403
+ && beanFactory .containsBean (IntegrationContextUtils .MESSAGE_HANDLER_FACTORY_BEAN_NAME );
402
404
}
403
405
404
406
private void createHandlerMethod () {
@@ -435,14 +437,14 @@ private void prepareEvaluationContext() throws Exception {
435
437
if (this .expectedType != null ) {
436
438
Assert .state (context .getTypeConverter ()
437
439
.canConvert (TypeDescriptor .valueOf ((this .method ).getReturnType ()), this .expectedType ),
438
- "Cannot convert to expected type (" + this .expectedType + ") from " + this .method );
440
+ () -> "Cannot convert to expected type (" + this .expectedType + ") from " + this .method );
439
441
}
440
442
}
441
443
else {
442
444
AnnotatedMethodFilter filter = new AnnotatedMethodFilter (this .annotationType , this .methodName ,
443
445
this .requiresReply );
444
446
Assert .state (canReturnExpectedType (filter , targetType , context .getTypeConverter ()),
445
- "Cannot convert to expected type (" + this .expectedType + ") from " + this .method );
447
+ () -> "Cannot convert to expected type (" + this .expectedType + ") from " + this .method );
446
448
context .registerMethodFilter (targetType , filter );
447
449
}
448
450
context .setVariable ("target" , this .targetObject );
@@ -703,9 +705,7 @@ && contentTypeIsJson(parameters.message)) {
703
705
704
706
}
705
707
catch (Exception e ) {
706
- if (logger .isDebugEnabled ()) {
707
- logger .debug ("Failed to convert from JSON" , e );
708
- }
708
+ logger .debug ("Failed to convert from JSON" , e );
709
709
}
710
710
}
711
711
}
@@ -899,13 +899,14 @@ else if (!Modifier.isPublic(method1.getModifiers())) {
899
899
}
900
900
901
901
Assert .state (!fallbackMethods .isEmpty () || !fallbackMessageMethods .isEmpty (),
902
- "Target object of type [" + this .targetObject .getClass () +
902
+ () -> "Target object of type [" + this .targetObject .getClass () +
903
903
"] has no eligible methods for handling Messages." );
904
904
905
- Assert .isNull (ambiguousFallbackType .get (), "Found ambiguous parameter type [" + ambiguousFallbackType
906
- + "] for method match: " + fallbackMethods .values ());
905
+ Assert .isNull (ambiguousFallbackType .get (),
906
+ () -> "Found ambiguous parameter type [" + ambiguousFallbackType +
907
+ "] for method match: " + fallbackMethods .values ());
907
908
Assert .isNull (ambiguousFallbackMessageGenericType .get (),
908
- "Found ambiguous parameter type ["
909
+ () -> "Found ambiguous parameter type ["
909
910
+ ambiguousFallbackMessageGenericType
910
911
+ "] for method match: "
911
912
+ fallbackMethods .values ());
@@ -967,8 +968,9 @@ private void findSingleSpecifMethodOnInterfacesIfProxy(final Object targetObject
967
968
}
968
969
969
970
private void checkSpelInvokerRequired (final Class <?> targetClass , Method methodArg , HandlerMethod handlerMethod ) {
970
- UseSpelInvoker useSpel = AnnotationUtils .findAnnotation (AopUtils .getMostSpecificMethod (methodArg , targetClass ),
971
- UseSpelInvoker .class );
971
+ UseSpelInvoker useSpel =
972
+ AnnotationUtils .findAnnotation (AopUtils .getMostSpecificMethod (methodArg , targetClass ),
973
+ UseSpelInvoker .class );
972
974
if (useSpel == null ) {
973
975
useSpel = AnnotationUtils .findAnnotation (targetClass , UseSpelInvoker .class );
974
976
}
@@ -1005,14 +1007,12 @@ private Class<?> getTargetClass(Object targetObject) {
1005
1007
try {
1006
1008
// Maybe a proxy with no target - e.g. gateway
1007
1009
Class <?>[] interfaces = ((Advised ) targetObject ).getProxiedInterfaces ();
1008
- if (interfaces != null && interfaces .length == 1 ) {
1010
+ if (interfaces .length == 1 ) {
1009
1011
targetClass = interfaces [0 ];
1010
1012
}
1011
1013
}
1012
1014
catch (Exception e ) {
1013
- if (logger .isDebugEnabled ()) {
1014
- logger .debug ("Exception trying to extract interface" , e );
1015
- }
1015
+ logger .debug ("Exception trying to extract interface" , e );
1016
1016
}
1017
1017
}
1018
1018
}
@@ -1133,7 +1133,10 @@ public String toString() {
1133
1133
}
1134
1134
1135
1135
private String generateExpression (Method method ) {
1136
- StringBuilder sb = new StringBuilder ("#target." + method .getName () + "(" );
1136
+ StringBuilder sb =
1137
+ new StringBuilder ("#target." )
1138
+ .append (method .getName ())
1139
+ .append ('(' );
1137
1140
Class <?>[] parameterTypes = method .getParameterTypes ();
1138
1141
Annotation [][] parameterAnnotations = method .getParameterAnnotations ();
1139
1142
boolean hasUnqualifiedMapParameter = false ;
@@ -1347,9 +1350,7 @@ public static class ParametersWrapper {
1347
1350
*/
1348
1351
public static Object getHeader (Map <?, ?> headers , String header ) {
1349
1352
Object object = headers .get (header );
1350
- if (object == null ) {
1351
- throw new IllegalArgumentException ("required header not available: " + header );
1352
- }
1353
+ Assert .notNull (object , () -> "required header not available: " + header );
1353
1354
return object ;
1354
1355
}
1355
1356
0 commit comments