Use bean CL for JdbcMessageStore.deserializer
Related to https://stackoverflow.com/questions/72305387/spring-integration-delayer-starts-sending-null-message-payloads-when-switched In some async use-cases (e.g. `DelayHandler`), the context classloader might be different for the data to be deserialized from message store. * Fix `JdbcMessageStore` to populate a bean `ClassLoader` into default `AllowListDeserializingConverter` from the application context. The provided `Deserializer` must ensure such a `ClassLoader` itself * Add warning message to the `LambdaMessageProcessor` when converter returns `null` for the payload it cannot convert to expected type. Cannot be raised as error since some applications may already rely on the `null` conversion result in their method arguments **Cherry-pick to `5.5.x`**
This commit is contained in:
committed by
Gary Russell
parent
cdcc986d11
commit
4f49038e17
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2021 the original author or authors.
|
||||
* Copyright 2016-2022 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.dsl;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -32,6 +33,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.convert.converter.Converter;
|
||||
import org.springframework.integration.config.EnableIntegration;
|
||||
import org.springframework.integration.config.IntegrationConverter;
|
||||
import org.springframework.integration.core.GenericSelector;
|
||||
import org.springframework.integration.handler.GenericHandler;
|
||||
import org.springframework.integration.handler.LambdaMessageProcessor;
|
||||
import org.springframework.integration.transformer.GenericTransformer;
|
||||
@@ -86,6 +88,24 @@ public class LambdaMessageProcessorTests {
|
||||
.isThrownBy(() -> lmp.processMessage(testMessage));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConversionToNull() {
|
||||
LambdaMessageProcessor lmp = new LambdaMessageProcessor(
|
||||
new GenericSelector<Date>() { // Must not be lambda
|
||||
|
||||
@Override
|
||||
public boolean accept(Date payload) {
|
||||
return payload == null;
|
||||
}
|
||||
|
||||
}, Date.class);
|
||||
lmp.setBeanFactory(this.beanFactory);
|
||||
GenericMessage<String> testMessage = new GenericMessage<>("foo");
|
||||
Object result = lmp.processMessage(testMessage);
|
||||
assertThat(result).isEqualTo(Boolean.TRUE);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
@Disabled("Until https://github.com/spring-projects/spring-integration/issues/3660")
|
||||
public void testCustomConverter() {
|
||||
|
||||
Reference in New Issue
Block a user