Skip to content

Commit 1409604

Browse files
committed
Polishing.
[#486][resolves #504] Signed-off-by: Mark Paluch <[email protected]>
1 parent 8018584 commit 1409604

File tree

1 file changed

+12
-19
lines changed

1 file changed

+12
-19
lines changed

src/main/java/io/r2dbc/postgresql/PostgresqlConnectionFactoryProvider.java

+12-19
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,8 @@ public final class PostgresqlConnectionFactoryProvider implements ConnectionFact
182182

183183
/**
184184
* Ssl mode alias (JDBC style). Default: disabled
185+
*
186+
* @since 0.9.2
185187
*/
186188
public static final Option<SSLMode> SSL_MODE_ALIAS = Option.valueOf("sslmode");
187189

@@ -298,25 +300,8 @@ private static void setupSsl(PostgresqlConnectionConfiguration.Builder builder,
298300
}
299301
});
300302

301-
mapper.from(SSL_MODE).map(it -> {
302-
303-
if (it instanceof String) {
304-
return SSLMode.fromValue(it.toString());
305-
}
306-
307-
return (SSLMode) it;
308-
309-
}).to(builder::sslMode).otherwise(() -> {
310-
311-
mapper.from(SSL_MODE_ALIAS).map(it -> {
312-
313-
if (it instanceof String) {
314-
return SSLMode.fromValue(it.toString());
315-
}
316-
317-
return (SSLMode) it;
318-
319-
}).to(builder::sslMode);
303+
mapper.from(SSL_MODE).map(PostgresqlConnectionFactoryProvider::toSSLMode).to(builder::sslMode).otherwise(() -> {
304+
mapper.from(SSL_MODE_ALIAS).map(PostgresqlConnectionFactoryProvider::toSSLMode).to(builder::sslMode);
320305
});
321306

322307
mapper.fromTyped(SSL_CERT).to(builder::sslCert);
@@ -343,6 +328,14 @@ private static void setupSsl(PostgresqlConnectionConfiguration.Builder builder,
343328
}).to(builder::sslHostnameVerifier);
344329
}
345330

331+
private static SSLMode toSSLMode(Object it) {
332+
if (it instanceof String) {
333+
return SSLMode.fromValue(it.toString());
334+
}
335+
336+
return (SSLMode) it;
337+
}
338+
346339
@SuppressWarnings("unchecked")
347340
private static Map<String, String> convertToMap(Object options) {
348341
if (options instanceof Map) {

0 commit comments

Comments
 (0)