Relax check on default data MimeType
If there is more than one non-basic codec (e.g. CBOR and JSON) RSocketRequester.Builder takes the mime type of the first one rather than giving up. It is a valid scenario (JSON for server responding to browser, and CBOR for client talking to server) and it is the default situation in Boot, and after all the point here is to pick some default as best as we can with the worst possible outcome being a server refusing the connection if it doesn't support the mime type. Beyond that applications can set the dataMimeType on the builder explicitly. To match that change this commit also ensures RSocketMessageHandler rejects proactively data mime types it does not support at the point of accepting a connection.
This commit is contained in:
@@ -46,7 +46,6 @@ import org.springframework.util.MimeTypeUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyInt;
|
||||
import static org.mockito.BDDMockito.given;
|
||||
@@ -131,22 +130,6 @@ public class DefaultRSocketRequesterBuilderTests {
|
||||
.isEqualTo(MimeTypeUtils.APPLICATION_JSON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void defaultDataMimeTypeWithMultipleCustomDecoderRegitered() {
|
||||
RSocketStrategies strategies = RSocketStrategies.builder()
|
||||
.decoder(new TestJsonDecoder(MimeTypeUtils.APPLICATION_JSON))
|
||||
.decoder(new TestJsonDecoder(MimeTypeUtils.APPLICATION_XML))
|
||||
.build();
|
||||
|
||||
assertThatThrownBy(() ->
|
||||
RSocketRequester
|
||||
.builder()
|
||||
.rsocketStrategies(strategies)
|
||||
.connect(this.transport)
|
||||
.block())
|
||||
.hasMessageContaining("Cannot select default data MimeType");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dataMimeTypeSet() {
|
||||
RSocketRequester requester = RSocketRequester.builder()
|
||||
|
||||
Reference in New Issue
Block a user