Closed as not planned
Closed as not planned
Description
Prior to spring-web-6.2.0 calling the mutate()
method of ServerWebExchange
and modifying the request headers would mutate the values in the calling instance of exchange object. This behavior matches the documentation of mutate()
method. But this no longer works with version 6.2.0.
Dependency package: spring-web
Last working version: 6.1.13
Issue found in version: 6.2.0
MRE
Java version: 17
Dependencies: spring-boot-starter-webflux:3.4.0 (spring-web:6.2.0), spring-boot-starter-test:3.4.0
Following test fails:
@Test
void mutateShouldDelegateBackModifiedHeadersToThisInstance() {
var mockServerHttpRequest = MockServerHttpRequest.get("/resource").build();
var exchange = MockServerWebExchange.from(mockServerHttpRequest);
String transactionId = UUID.randomUUID().toString();
exchange.mutate().request(builder -> builder
.header("Transaction-Id", transactionId));
String transactionIdFromExchange = exchange.getRequest().getHeaders().getFirst("Transaction-Id");
Assertions.assertEquals(transactionId, transactionIdFromExchange);
}
Using mutate().build()
and using the returned exchange object still works as it did in version 6.1.13.
@Test
void mutateThenBuildShouldReturnModifiedHeaders() {
var mockServerHttpRequest = MockServerHttpRequest.get("/resource").build();
var exchange = MockServerWebExchange.from(mockServerHttpRequest);
String transactionId = UUID.randomUUID().toString();
var mutatedExchange = exchange.mutate().request(builder -> builder
.header("Transaction-Id", transactionId)
).build();
String transactionIdFromExchange = mutatedExchange.getRequest().getHeaders().getFirst("Transaction-Id");
Assertions.assertEquals(transactionId, transactionIdFromExchange);
}