-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Spring Integration 7.0 to 7.1 Migration Guide
Spring Integration 7.1 has updated the TestUtils.getPropertyValue() method to use generic type inference instead of requiring an explicit Class<T> parameter.
The three-parameter method signature:
public static <T> @Nullable T getPropertyValue(Object root, String propertyPath, Class<T> type)
has been deprecated in favor of the two-parameter generic method:
public static <T> @Nullable T getPropertyValue(Object root, String propertyPath)
Old code (deprecated):
LoadBalancingStrategy strategy = TestUtils.getPropertyValue(channel, "dispatcher.loadBalancingStrategy", LoadBalancingStrategy.class);
Boolean autoStartup = TestUtils.getPropertyValue(adapter, "autoStartup", Boolean.class);
New code (recommended):
Option 1: Type inference with variable assignment
LoadBalancingStrategy strategy = TestUtils.getPropertyValue(channel, "dispatcher.loadBalancingStrategy");
Option 2: Explicit generic type parameter (required in some contexts like assertions);
assertThat(TestUtils.<LoadBalancingStrategy>getPropertyValue(channel, "dispatcher.loadBalancingStrategy")).isNotNull();
// or if the type is object then you can AssertJ's `assertThatObject`.
assertThatObject(TestUtils.getPropertyValue(adapter, "outputChannel")).isSameAs(autoChannel);
Both Mqttv5PahoMessageDrivenChannelAdapter and Mqttv5PahoMessageHandler use a org.springframework.messaging.converter.MessageConverter abstraction for (de)serializing to/from MQTT message.
However, they did it for years wrong way: the MessageConverter.fromMessage() contract is for inbound messages, therefore for deserializing over the network bytes into an application object; the MessageConverter.toMessage() is for serializing outbound application object to the network bytes.
So, the logic in these channel adapters was inverted and respective injected org.springframework.messaging.converter.MessageConverter had to be adjusted this or other way to meet channel adapters expectation.
Now they've been fix to follow org.springframework.messaging.converter.MessageConverter contract.