Skip to content

Commit 5425fbb

Browse files
committed
Ensure Reactor-Netty Forward Compatibility
Motivation: A change in `r.n.t.SslProvider.ProtocolSslContextSpec` breaks forward compatibility. Modifications: Remove Usage of `ProtocolSslContextSpec`. Result: The SSL context is now correctly initialized under the old reactor-netty version, ensuring forward compatibility.
1 parent e211cd8 commit 5425fbb

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

Diff for: r2dbc-mysql/src/main/java/io/asyncer/r2dbc/mysql/client/SslBridgeHandler.java

+12-16
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@
3333
import io.netty.handler.ssl.util.InsecureTrustManagerFactory;
3434
import io.netty.util.internal.logging.InternalLogger;
3535
import io.netty.util.internal.logging.InternalLoggerFactory;
36+
import reactor.core.Exceptions;
3637
import reactor.netty.tcp.SslProvider;
3738

3839
import javax.net.ssl.HostnameVerifier;
3940
import javax.net.ssl.SSLEngine;
4041
import javax.net.ssl.SSLException;
4142
import java.io.File;
4243
import java.net.InetSocketAddress;
43-
import java.util.function.Consumer;
4444

4545
import static io.asyncer.r2dbc.mysql.internal.util.AssertUtils.requireNonNull;
4646
import static io.netty.handler.ssl.SslProvider.JDK;
@@ -151,10 +151,16 @@ private void handleSslState(ChannelHandlerContext ctx, SslState state) {
151151
switch (state) {
152152
case BRIDGING:
153153
logger.debug("SSL event triggered, enable SSL handler to pipeline");
154-
155-
SslProvider sslProvider = SslProvider.builder()
156-
.sslContext(MySqlSslContextSpec.forClient(ssl, context))
157-
.build();
154+
final SslProvider sslProvider;
155+
try {
156+
// Workaround for a forward incompatible change in reactor-netty version 1.2.0
157+
// See: https://github.com/reactor/reactor-netty/commit/6d0c24d83a7c5b15e403475272293f847415191c
158+
sslProvider = SslProvider.builder()
159+
.sslContext(MySqlSslContextSpec.forClient(ssl, context).sslContext())
160+
.build();
161+
} catch (SSLException e) {
162+
throw Exceptions.propagate(e);
163+
}
158164
SslHandler sslHandler = sslProvider.getSslContext().newHandler(ctx.alloc());
159165

160166
this.sslEngine = sslHandler.engine();
@@ -195,24 +201,14 @@ private static boolean isTls13Enabled(ConnectionContext context) {
195201
|| (version.isGreaterThanOrEqualTo(MYSQL_5_6_0) && version.isEnterprise());
196202
}
197203

198-
private static final class MySqlSslContextSpec implements SslProvider.ProtocolSslContextSpec {
204+
private static final class MySqlSslContextSpec {
199205

200206
private final SslContextBuilder builder;
201207

202208
private MySqlSslContextSpec(SslContextBuilder builder) {
203209
this.builder = builder;
204210
}
205211

206-
@Override
207-
public MySqlSslContextSpec configure(Consumer<SslContextBuilder> customizer) {
208-
requireNonNull(customizer, "customizer must not be null");
209-
210-
customizer.accept(builder);
211-
212-
return this;
213-
}
214-
215-
@Override
216212
public SslContext sslContext() throws SSLException {
217213
return builder.build();
218214
}

0 commit comments

Comments
 (0)