Skip to content

Commit ebec500

Browse files
committed
Upgrade dependencies to the latest snapshots
* Fix HTTP & WebFlux for a new CORS logic when `*` pattern is used together with `allowCredentials` * Fix RSocket module for deprecated API in SF * The deprecated RMI API is left for the upcoming changes
1 parent 8b16aed commit ebec500

File tree

7 files changed

+73
-30
lines changed

7 files changed

+73
-30
lines changed

build.gradle

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,17 @@ ext {
9191
reactorVersion = '2020.0.0-M1'
9292
resilience4jVersion = '1.5.0'
9393
romeToolsVersion = '1.12.2'
94-
rsocketVersion = '1.0.1'
94+
rsocketVersion = '1.1.0-SNAPSHOT'
9595
saajVersion = '1.5.2'
9696
servletApiVersion = '4.0.1'
9797
smackVersion = '4.3.4'
9898
soapVersion = '1.4.0'
99-
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.3.0-M1'
100-
springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2020.0.0-M1'
99+
springAmqpVersion = project.hasProperty('springAmqpVersion') ? project.springAmqpVersion : '2.3.0-SNAPSHOT'
100+
springDataVersion = project.hasProperty('springDataVersion') ? project.springDataVersion : '2020.0.0-SNAPSHOT'
101101
springKafkaVersion = '2.5.4.BUILD-SNAPSHOT'
102-
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '5.4.0-M1'
102+
springSecurityVersion = project.hasProperty('springSecurityVersion') ? project.springSecurityVersion : '5.4.0-SNAPSHOT'
103103
springRetryVersion = '1.3.0'
104-
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.3.0-M1'
104+
springVersion = project.hasProperty('springVersion') ? project.springVersion : '5.3.0-SNAPSHOT'
105105
springWsVersion = '3.0.9.RELEASE'
106106
tomcatVersion = "9.0.36"
107107
xstreamVersion = '1.4.12'

spring-integration-http/src/main/java/org/springframework/integration/http/inbound/IntegrationRequestMappingHandlerMapping.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.lang.reflect.Method;
2020
import java.util.Arrays;
2121
import java.util.HashMap;
22+
import java.util.List;
2223
import java.util.Map;
2324
import java.util.concurrent.atomic.AtomicBoolean;
2425

@@ -175,10 +176,19 @@ protected CorsConfiguration initCorsConfiguration(Object handler, Method method,
175176
for (RequestMethod requestMethod : crossOrigin.getMethod()) {
176177
config.addAllowedMethod(requestMethod.name());
177178
}
178-
config.setAllowedOrigins(Arrays.asList(crossOrigin.getOrigin()));
179179
config.setAllowedHeaders(Arrays.asList(crossOrigin.getAllowedHeaders()));
180180
config.setExposedHeaders(Arrays.asList(crossOrigin.getExposedHeaders()));
181-
config.setAllowCredentials(crossOrigin.getAllowCredentials());
181+
Boolean allowCredentials = crossOrigin.getAllowCredentials();
182+
config.setAllowCredentials(allowCredentials);
183+
List<String> allowedOrigins = Arrays.asList(crossOrigin.getOrigin());
184+
if (Boolean.TRUE.equals(allowCredentials)
185+
&& CollectionUtils.contains(allowedOrigins.iterator(), CorsConfiguration.ALL)) {
186+
config.setAllowedOriginPatterns(allowedOrigins);
187+
}
188+
else {
189+
config.setAllowedOrigins(allowedOrigins);
190+
}
191+
182192
if (crossOrigin.getMaxAge() != -1) {
183193
config.setMaxAge(crossOrigin.getMaxAge());
184194
}

spring-integration-http/src/test/java/org/springframework/integration/http/inbound/CrossOriginTests.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ public void defaultEndpointWithCrossOrigin() throws Exception {
8585
CorsConfiguration config = getCorsConfiguration(chain, false);
8686
assertThat(config).isNotNull();
8787
assertThat(config.getAllowedMethods().toArray()).isEqualTo(new String[] { "GET" });
88-
assertThat(config.getAllowedOrigins().toArray()).isEqualTo(new String[] { "*" });
88+
assertThat(config.getAllowedOrigins()).isNull();
89+
assertThat(config.getAllowedOriginPatterns().toArray()).isEqualTo(new String[] { "*" });
8990
assertThat(config.getAllowCredentials()).isTrue();
9091
assertThat(config.getAllowedHeaders().toArray()).isEqualTo(new String[] { "*" });
9192
assertThat(config.getExposedHeaders()).isEmpty();
@@ -116,7 +117,8 @@ public void preFlightRequest() throws Exception {
116117
CorsConfiguration config = getCorsConfiguration(chain, true);
117118
assertThat(config).isNotNull();
118119
assertThat(config.getAllowedMethods().toArray()).isEqualTo(new String[] { "GET" });
119-
assertThat(config.getAllowedOrigins().toArray()).isEqualTo(new String[] { "*" });
120+
assertThat(config.getAllowedOrigins()).isNull();
121+
assertThat(config.getAllowedOriginPatterns().toArray()).isEqualTo(new String[] { "*" });
120122
assertThat(config.getAllowCredentials()).isTrue();
121123
assertThat(config.getAllowedHeaders().toArray()).isEqualTo(new String[] { "*" });
122124
assertThat(config.getExposedHeaders()).isEmpty();
@@ -133,7 +135,8 @@ public void ambiguousHeaderPreFlightRequest() throws Exception {
133135
CorsConfiguration config = getCorsConfiguration(chain, true);
134136
assertThat(config).isNotNull();
135137
assertThat(config.getAllowedMethods().toArray()).isEqualTo(new String[] { "*" });
136-
assertThat(config.getAllowedOrigins().toArray()).isEqualTo(new String[] { "*" });
138+
assertThat(config.getAllowedOrigins()).isNull();
139+
assertThat(config.getAllowedOriginPatterns().toArray()).isEqualTo(new String[] { "*" });
137140
assertThat(config.getAllowedHeaders().toArray()).isEqualTo(new String[] { "*" });
138141
assertThat(config.getAllowCredentials()).isTrue();
139142
assertThat(config.getExposedHeaders()).isNull();
@@ -149,7 +152,8 @@ public void ambiguousProducesPreFlightRequest() throws Exception {
149152
CorsConfiguration config = getCorsConfiguration(chain, true);
150153
assertThat(config).isNotNull();
151154
assertThat(config.getAllowedMethods().toArray()).isEqualTo(new String[] { "*" });
152-
assertThat(config.getAllowedOrigins().toArray()).isEqualTo(new String[] { "*" });
155+
assertThat(config.getAllowedOrigins()).isNull();
156+
assertThat(config.getAllowedOriginPatterns().toArray()).isEqualTo(new String[] { "*" });
153157
assertThat(config.getAllowedHeaders().toArray()).isEqualTo(new String[] { "*" });
154158
assertThat(config.getAllowCredentials()).isTrue();
155159
assertThat(config.getExposedHeaders()).isNull();

spring-integration-rsocket/src/main/java/org/springframework/integration/rsocket/ClientRSocketConnector.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,12 @@
2626
import org.springframework.util.Assert;
2727
import org.springframework.util.MimeType;
2828

29+
import io.rsocket.core.RSocketConnector;
2930
import io.rsocket.transport.ClientTransport;
3031
import io.rsocket.transport.netty.client.TcpClientTransport;
3132
import io.rsocket.transport.netty.client.WebsocketClientTransport;
32-
import reactor.core.Disposable;
3333
import reactor.core.publisher.Mono;
34+
import reactor.core.publisher.Sinks;
3435

3536
/**
3637
* A client {@link AbstractRSocketConnector} extension to the RSocket connection.
@@ -82,7 +83,7 @@ public ClientRSocketConnector(URI uri) {
8283
/**
8384
* Instantiate a connector based on the provided {@link ClientTransport}.
8485
* @param clientTransport the {@link ClientTransport} to use.
85-
* @see RSocketRequester.Builder#connect(ClientTransport)
86+
* @see RSocketRequester.Builder#transport(ClientTransport)
8687
*/
8788
public ClientRSocketConnector(ClientTransport clientTransport) {
8889
super(new IntegrationRSocketMessageHandler());
@@ -175,18 +176,27 @@ public void setSetupData(Object setupData) {
175176
public void afterPropertiesSet() {
176177
super.afterPropertiesSet();
177178

178-
this.rsocketRequesterMono =
179+
Sinks.StandaloneMonoSink<RSocketConnector> rsocketConnector = Sinks.promise();
180+
181+
RSocketRequester rsocketRequester =
179182
RSocketRequester.builder()
180183
.dataMimeType(getDataMimeType())
181184
.metadataMimeType(getMetadataMimeType())
182185
.rsocketStrategies(getRSocketStrategies())
183186
.setupData(this.setupData)
184187
.setupRoute(this.setupRoute, this.setupRouteVars)
185-
.rsocketConnector(this.connectorConfigurer)
186-
.rsocketConnector((connector) ->
187-
connector.acceptor(this.rSocketMessageHandler.responder()))
188188
.apply((builder) -> this.setupMetadata.forEach(builder::setupMetadata))
189-
.connect(this.clientTransport)
189+
.rsocketConnector(this.connectorConfigurer)
190+
.rsocketConnector((connector) -> {
191+
connector.acceptor(this.rSocketMessageHandler.responder());
192+
rsocketConnector.success(connector);
193+
})
194+
.transport(this.clientTransport);
195+
196+
this.rsocketRequesterMono =
197+
rsocketConnector.asMono()
198+
.flatMap(rSocketConnector -> rSocketConnector.connect(this.clientTransport))
199+
.thenReturn(rsocketRequester)
190200
.cache();
191201
}
192202

@@ -205,8 +215,7 @@ protected void doStart() {
205215
@Override
206216
public void destroy() {
207217
this.rsocketRequesterMono
208-
.map(RSocketRequester::rsocket)
209-
.doOnNext(Disposable::dispose)
218+
.doOnNext(RSocketRequester::dispose)
210219
.subscribe();
211220
}
212221

spring-integration-rsocket/src/main/resources/org/springframework/integration/rsocket/config/spring-integration-rsocket.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<xsd:annotation>
2323
<xsd:documentation>
2424
Configures a Messaging Gateway Endpoint for the
25-
'org.springframework.integration.rsocket.inbound.RSocketInboundGateway to receive RSocket
25+
'org.springframework.integration.rsocket.inbound.RSocketInboundGateway' to receive RSocket
2626
requests and produce RSocket responses.
2727
</xsd:documentation>
2828
</xsd:annotation>

spring-integration-rsocket/src/test/java/org/springframework/integration/rsocket/outbound/RSocketOutboundGatewayIntegrationTests.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@
5959
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
6060

6161
import io.rsocket.RSocket;
62+
import io.rsocket.core.RSocketConnector;
6263
import io.rsocket.core.RSocketServer;
6364
import io.rsocket.frame.decoder.PayloadDecoder;
65+
import io.rsocket.transport.netty.client.TcpClientTransport;
6466
import io.rsocket.transport.netty.server.CloseableChannel;
6567
import io.rsocket.transport.netty.server.TcpServerTransport;
6668
import reactor.core.Disposable;
@@ -497,14 +499,22 @@ public static class ClientConfig extends CommonConfig {
497499
@Bean(destroyMethod = "dispose")
498500
@Nullable
499501
public RSocket rsocketForServerRequests() {
500-
return RSocketRequester.builder()
502+
Sinks.StandaloneMonoSink<RSocketConnector> rsocketConnector = Sinks.promise();
503+
504+
RSocketRequester.builder()
501505
.setupRoute("clientConnect")
502-
.rsocketConnector(connector ->
503-
connector.acceptor(
504-
RSocketMessageHandler.responder(RSocketStrategies.create(), controller())))
505-
.connectTcp("localhost", server.address().getPort())
506-
.block()
507-
.rsocket();
506+
.rsocketConnector(connector -> {
507+
connector.acceptor(
508+
RSocketMessageHandler.responder(RSocketStrategies.create(), controller()));
509+
rsocketConnector.success(connector);
510+
})
511+
.tcp("localhost", server.address().getPort());
512+
513+
return rsocketConnector.asMono()
514+
.flatMap(rSocketConnector ->
515+
rSocketConnector.connect(
516+
TcpClientTransport.create("localhost", server.address().getPort())))
517+
.block();
508518
}
509519

510520
@Bean

spring-integration-webflux/src/main/java/org/springframework/integration/webflux/inbound/WebFluxIntegrationRequestMappingHandlerMapping.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import java.lang.reflect.Method;
2020
import java.util.Arrays;
21+
import java.util.List;
2122
import java.util.concurrent.atomic.AtomicBoolean;
2223

2324
import org.springframework.beans.BeansException;
@@ -151,10 +152,19 @@ protected CorsConfiguration initCorsConfiguration(Object handler, Method method,
151152
for (RequestMethod requestMethod : crossOrigin.getMethod()) {
152153
config.addAllowedMethod(requestMethod.name());
153154
}
154-
config.setAllowedOrigins(Arrays.asList(crossOrigin.getOrigin()));
155155
config.setAllowedHeaders(Arrays.asList(crossOrigin.getAllowedHeaders()));
156156
config.setExposedHeaders(Arrays.asList(crossOrigin.getExposedHeaders()));
157-
config.setAllowCredentials(crossOrigin.getAllowCredentials());
157+
Boolean allowCredentials = crossOrigin.getAllowCredentials();
158+
config.setAllowCredentials(allowCredentials);
159+
List<String> allowedOrigins = Arrays.asList(crossOrigin.getOrigin());
160+
if (Boolean.TRUE.equals(allowCredentials)
161+
&& CollectionUtils.contains(allowedOrigins.iterator(), CorsConfiguration.ALL)) {
162+
config.setAllowedOriginPatterns(allowedOrigins);
163+
}
164+
else {
165+
config.setAllowedOrigins(allowedOrigins);
166+
}
167+
158168
if (crossOrigin.getMaxAge() != -1) {
159169
config.setMaxAge(crossOrigin.getMaxAge());
160170
}

0 commit comments

Comments
 (0)