From 5beb7edfbb4ca56892a5c682aae36b6ad81007ee Mon Sep 17 00:00:00 2001 From: Brian Clozel Date: Wed, 24 Jul 2019 20:39:55 +0200 Subject: [PATCH] Reinstate RSocket codecs configuration ordering Since spring-projects/spring-framework#23314 and the following commit spring-projects/spring-framework@be4facef1b, the RSocket codec selection is relaxed and the order of configured commits matters again. This commit ensures that the CBOR codec is configured ahead of the JSON codec so that it can be chosen first if no data mime type is specified when a connection is established with a client requester. --- .../rsocket/RSocketStrategiesAutoConfiguration.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java index 1b4b705536a..4a3faa25cb0 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/rsocket/RSocketStrategiesAutoConfiguration.java @@ -31,6 +31,7 @@ import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; import org.springframework.boot.rsocket.messaging.RSocketStrategiesCustomizer; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.core.annotation.Order; import org.springframework.http.MediaType; import org.springframework.http.codec.cbor.Jackson2CborDecoder; import org.springframework.http.codec.cbor.Jackson2CborEncoder; @@ -65,6 +66,7 @@ public class RSocketStrategiesAutoConfiguration { private static final MediaType[] SUPPORTED_TYPES = { MediaType.APPLICATION_CBOR }; @Bean + @Order(0) @ConditionalOnBean(Jackson2ObjectMapperBuilder.class) public RSocketStrategiesCustomizer jacksonCborRSocketStrategyCustomizer(Jackson2ObjectMapperBuilder builder) { return (strategy) -> { @@ -84,6 +86,7 @@ public class RSocketStrategiesAutoConfiguration { new MediaType("application", "*+json") }; @Bean + @Order(1) @ConditionalOnBean(ObjectMapper.class) public RSocketStrategiesCustomizer jacksonJsonRSocketStrategyCustomizer(ObjectMapper objectMapper) { return (strategy) -> {