From 20ed93a8d8dd086efd5a9da12e1d268f0cc1f45f Mon Sep 17 00:00:00 2001 From: Artem Bilan Date: Tue, 20 Nov 2018 15:25:56 -0500 Subject: [PATCH] Optimize type conversion in LambdaMessageProcessor --- .../integration/handler/LambdaMessageProcessor.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java index dde3c0a814..c75d5ca120 100644 --- a/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java +++ b/spring-integration-core/src/main/java/org/springframework/integration/handler/LambdaMessageProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2017 the original author or authors. + * Copyright 2016-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.springframework.integration.support.utils.IntegrationUtils; import org.springframework.messaging.Message; import org.springframework.messaging.MessageHandlingException; import org.springframework.util.Assert; +import org.springframework.util.ClassUtils; import org.springframework.util.ReflectionUtils; /** @@ -114,7 +115,9 @@ public class LambdaMessageProcessor implements MessageProcessor, BeanFac } } else { - if (this.payloadType != null) { + if (this.payloadType != null && + !ClassUtils.isAssignable(this.payloadType.getType(), message.getPayload().getClass())) { + if (Message.class.isAssignableFrom(this.payloadType.getType())) { args[i] = message; }