Skip to content

Commit c934adb

Browse files
committed
Various fixes
* Adapt to WebFlux deprecations: spring-projects/spring-framework#25751 * Back to SNAPSHOTs * Fix new Sonar smells
1 parent 0cad53a commit c934adb

File tree

6 files changed

+44
-48
lines changed

6 files changed

+44
-48
lines changed

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,20 +90,20 @@ ext {
9090
pahoMqttClientVersion = '1.2.4'
9191
postgresVersion = '42.2.14'
9292
r2dbch2Version='0.8.4.RELEASE'
93-
reactorVersion = '2020.0.0-RC1'
93+
reactorVersion = '2020.0.0-SNAPSHOT'
9494
resilience4jVersion = '1.5.0'
9595
romeToolsVersion = '1.15.0'
9696
rsocketVersion = '1.1.0-M2'
9797
saajVersion = '1.5.2'
9898
servletApiVersion = '4.0.1'
9999
smackVersion = '4.3.4'
100100
soapVersion = '1.4.0'
101-
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.3.0-M3'
102-
springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2020.0.0-RC1'
103-
springKafkaVersion = '2.6.1'
101+
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.3.0-SNAPSHOT'
102+
springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2020.0.0-SNAPSHOT'
103+
springKafkaVersion = '2.6.2-SNAPSHOT'
104104
springRetryVersion = '1.3.0'
105105
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '5.4.0'
106-
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.3.0-RC1'
106+
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.3.0-SNAPSHOT'
107107
springWsVersion = '3.0.10.RELEASE'
108108
tomcatVersion = "9.0.38"
109109
xstreamVersion = '1.4.13'

spring-integration-core/src/main/java/org/springframework/integration/support/json/MimeTypeSerializer.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@
2121
import org.springframework.util.MimeType;
2222

2323
import com.fasterxml.jackson.core.JsonGenerator;
24-
import com.fasterxml.jackson.databind.JsonSerializer;
2524
import com.fasterxml.jackson.databind.SerializerProvider;
2625
import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
2726
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
2827

2928
/**
30-
* Simple {@link JsonSerializer} extension to represent a {@link MimeType} object in the
29+
* Simple {@link StdSerializer} extension to represent a {@link MimeType} object in the
3130
* target JSON as a plain string.
3231
*
3332
* @author Artem Bilan

spring-integration-mongodb/src/main/java/org/springframework/integration/mongodb/dsl/ReactiveMongoDbMessageHandlerSpec.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,13 @@
2424
import org.springframework.expression.Expression;
2525
import org.springframework.expression.common.LiteralExpression;
2626
import org.springframework.integration.dsl.ComponentsRegistration;
27-
import org.springframework.integration.dsl.MessageHandlerSpec;
2827
import org.springframework.integration.dsl.ReactiveMessageHandlerSpec;
2928
import org.springframework.integration.expression.FunctionExpression;
3029
import org.springframework.integration.mongodb.outbound.ReactiveMongoDbStoringMessageHandler;
3130
import org.springframework.messaging.Message;
3231

3332
/**
34-
* A {@link MessageHandlerSpec} extension for the Reactive MongoDb Outbound endpoint
33+
* A {@link ReactiveMessageHandlerSpec} extension for the Reactive MongoDb Outbound endpoint
3534
* {@link ReactiveMongoDbStoringMessageHandler}.
3635
*
3736
* @author Artem Bilan

spring-integration-webflux/src/main/java/org/springframework/integration/webflux/outbound/WebFluxRequestExecutingMessageHandler.java

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -298,38 +298,39 @@ private WebClient.RequestBodySpec createRequestBodySpec(Object uri, HttpMethod h
298298
}
299299

300300
private Mono<ClientResponse> exchangeForResponseMono(WebClient.RequestBodySpec requestSpec) {
301-
return requestSpec.exchange()
302-
.flatMap(response -> {
301+
return requestSpec.retrieve()
302+
.onStatus(HttpStatus::isError, response -> {
303303
HttpStatus httpStatus = response.statusCode();
304-
if (httpStatus.isError()) {
305-
return response.body(BodyExtractors.toDataBuffers())
306-
.reduce(DataBuffer::write)
307-
.map(dataBuffer -> {
308-
byte[] bytes = new byte[dataBuffer.readableByteCount()];
309-
dataBuffer.read(bytes);
310-
DataBufferUtils.release(dataBuffer);
311-
return bytes;
312-
})
313-
.defaultIfEmpty(new byte[0])
314-
.map(bodyBytes -> {
315-
throw new WebClientResponseException(
316-
"ClientResponse has erroneous status code: "
317-
+ httpStatus.value() + " "
318-
+ httpStatus.getReasonPhrase(),
319-
httpStatus.value(),
320-
httpStatus.getReasonPhrase(),
321-
response.headers().asHttpHeaders(),
322-
bodyBytes,
323-
response.headers().contentType()
324-
.map(MimeType::getCharset)
325-
.orElse(StandardCharsets.ISO_8859_1));
326-
}
327-
);
328-
}
329-
else {
330-
return Mono.just(response);
331-
}
332-
});
304+
return response.body(BodyExtractors.toDataBuffers())
305+
.reduce(DataBuffer::write)
306+
.map(dataBuffer -> {
307+
byte[] bytes = new byte[dataBuffer.readableByteCount()];
308+
dataBuffer.read(bytes);
309+
DataBufferUtils.release(dataBuffer);
310+
return bytes;
311+
})
312+
.defaultIfEmpty(new byte[0])
313+
.map(bodyBytes -> {
314+
throw new WebClientResponseException(
315+
"ClientResponse has erroneous status code: "
316+
+ httpStatus.value() + " "
317+
+ httpStatus.getReasonPhrase(),
318+
httpStatus.value(),
319+
httpStatus.getReasonPhrase(),
320+
response.headers().asHttpHeaders(),
321+
bodyBytes,
322+
response.headers().contentType()
323+
.map(MimeType::getCharset)
324+
.orElse(StandardCharsets.ISO_8859_1));
325+
}
326+
);
327+
})
328+
.toEntityList(DataBuffer.class)
329+
.map((entity) ->
330+
ClientResponse.create(entity.getStatusCode())
331+
.headers((headers) -> headers.addAll(entity.getHeaders()))
332+
.body(Flux.fromIterable(entity.getBody())) // NOSONAR - not null according toEntityList()
333+
.build());
333334
}
334335

335336
@Nullable

spring-integration-zeromq/src/main/java/org/springframework/integration/zeromq/dsl/ZeroMqMessageHandlerSpec.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
import org.zeromq.ZMQ;
2525

2626
import org.springframework.expression.Expression;
27-
import org.springframework.integration.dsl.MessageHandlerSpec;
2827
import org.springframework.integration.dsl.ReactiveMessageHandlerSpec;
2928
import org.springframework.integration.expression.FunctionExpression;
3029
import org.springframework.integration.mapping.OutboundMessageMapper;
@@ -33,7 +32,7 @@
3332
import org.springframework.messaging.converter.MessageConverter;
3433

3534
/**
36-
* The {@link MessageHandlerSpec} extension for {@link ZeroMqMessageHandler}.
35+
* The {@link ReactiveMessageHandlerSpec} extension for {@link ZeroMqMessageHandler}.
3736
*
3837
* @author Artem Bilan
3938
*

spring-integration-zeromq/src/main/java/org/springframework/integration/zeromq/dsl/ZeroMqMessageProducerSpec.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,10 @@
2222
import org.zeromq.SocketType;
2323
import org.zeromq.ZContext;
2424
import org.zeromq.ZMQ;
25-
import org.zeromq.ZMsg;
2625

2726
import org.springframework.integration.dsl.MessageProducerSpec;
2827
import org.springframework.integration.mapping.InboundMessageMapper;
29-
import org.springframework.integration.zeromq.ZeroMqHeaders;
3028
import org.springframework.integration.zeromq.inbound.ZeroMqMessageProducer;
31-
import org.springframework.messaging.Message;
3229
import org.springframework.messaging.converter.MessageConverter;
3330

3431
/**
@@ -79,9 +76,10 @@ public ZeroMqMessageProducerSpec messageConverter(MessageConverter messageConver
7976
}
8077

8178
/**
82-
* Whether raw {@link ZMsg} is present as a payload of message to produce or
83-
* it is fully converted to a {@link Message} including {@link ZeroMqHeaders#TOPIC} header (if any).
84-
* @param receiveRaw to convert from {@link ZMsg} or not; defaults to convert.
79+
* Whether raw {@link org.zeromq.ZMsg} is present as a payload of message to produce or
80+
* it is fully converted to a {@link org.springframework.messaging.Message} including
81+
* {@link org.springframework.integration.zeromq.ZeroMqHeaders#TOPIC} header (if any).
82+
* @param receiveRaw to convert from {@link org.zeromq.ZMsg} or not; defaults to convert.
8583
* @return the spec
8684
*/
8785
public ZeroMqMessageProducerSpec receiveRaw(boolean receiveRaw) {

0 commit comments

Comments
 (0)