Skip to content

Commit faeda6f

Browse files
committed
Polish
1 parent 4c71e81 commit faeda6f

File tree

2 files changed

+12
-14
lines changed

2 files changed

+12
-14
lines changed

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,9 @@ private ConnectionFactoryOptions delegateFactoryOptions(ConnectionFactoryOptions
221221
String[] protocols = protocol.split(COLON, 2);
222222
String driverDelegate = protocols[0];
223223
String protocolDelegate = (protocols.length != 2) ? "" : protocols[1];
224-
ConnectionFactoryOptions newOptions = ConnectionFactoryOptions.builder().from(options)
224+
return ConnectionFactoryOptions.builder().from(options)
225225
.option(ConnectionFactoryOptions.DRIVER, driverDelegate)
226226
.option(ConnectionFactoryOptions.PROTOCOL, protocolDelegate).build();
227-
return newOptions;
228227
}
229228

230229
ConnectionPoolConfiguration connectionPoolConfiguration(ConnectionFactoryOptions options,
@@ -253,8 +252,7 @@ ConnectionPoolConfiguration connectionPoolConfiguration(ConnectionFactoryOptions
253252
map.from(options.getValue(PoolingConnectionFactoryProvider.VALIDATION_QUERY)).to(builder::validationQuery);
254253
map.from((Object) options.getValue(PoolingConnectionFactoryProvider.VALIDATION_DEPTH))
255254
.as(this::toValidationDepth).to(builder::validationDepth);
256-
ConnectionPoolConfiguration build = builder.build();
257-
return build;
255+
return builder.build();
258256
}
259257

260258
private Integer toInteger(Object object) {

spring-boot-project/spring-boot/src/test/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilderTests.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ void buildWhenDerivedFromPoolReturnsNewNonPooledConnectionFactory() {
188188
@SuppressWarnings({ "rawtypes", "unchecked" })
189189
@MethodSource("poolingConnectionProviderOptions")
190190
void optionIsMappedWhenCreatingPoolConfiguration(Option option) {
191-
String url = "r2dbc:pool:h2:mem:///" + UUID.randomUUID().toString();
191+
String url = "r2dbc:pool:h2:mem:///" + UUID.randomUUID();
192192
ExpectedOption expectedOption = ExpectedOption.get(option);
193193
ConnectionFactoryOptions options = ConnectionFactoryBuilder.withUrl(url).configure((builder) -> builder
194194
.option(PoolingConnectionFactoryProvider.POOL_NAME, "defaultName").option(option, expectedOption.value))
@@ -202,7 +202,7 @@ void optionIsMappedWhenCreatingPoolConfiguration(Option option) {
202202
@SuppressWarnings({ "rawtypes", "unchecked" })
203203
@MethodSource("poolingConnectionProviderOptions")
204204
void stringlyTypedOptionIsMappedWhenCreatingPoolConfiguration(Option option) {
205-
String url = "r2dbc:pool:h2:mem:///" + UUID.randomUUID().toString();
205+
String url = "r2dbc:pool:h2:mem:///" + UUID.randomUUID();
206206
ExpectedOption expectedOption = ExpectedOption.get(option);
207207
ConnectionFactoryOptions options = ConnectionFactoryBuilder.withUrl(url)
208208
.configure((builder) -> builder.option(PoolingConnectionFactoryProvider.POOL_NAME, "defaultName")
@@ -213,21 +213,21 @@ void stringlyTypedOptionIsMappedWhenCreatingPoolConfiguration(Option option) {
213213
assertThat(configuration).extracting(expectedOption.property).isEqualTo(expectedOption.value);
214214
}
215215

216-
private void assertMatchingOptions(ConnectionFactoryOptions actualOptions, ConnectionFactoryOptions expectedOptions,
217-
Option<?>... optionsToCheck) {
218-
for (Option<?> option : optionsToCheck) {
219-
assertThat(actualOptions.getValue(option)).as(option.name()).isEqualTo(expectedOptions.getValue(option));
220-
}
221-
}
222-
223216
private static Iterable<Arguments> poolingConnectionProviderOptions() {
224217
List<Arguments> arguments = new ArrayList<>();
225218
ReflectionUtils.doWithFields(PoolingConnectionFactoryProvider.class,
226-
(field) -> arguments.add(Arguments.of((Option<?>) ReflectionUtils.getField(field, null))),
219+
(field) -> arguments.add(Arguments.of(ReflectionUtils.getField(field, null))),
227220
(field) -> Option.class.equals(field.getType()));
228221
return arguments;
229222
}
230223

224+
private void assertMatchingOptions(ConnectionFactoryOptions actualOptions, ConnectionFactoryOptions expectedOptions,
225+
Option<?>... optionsToCheck) {
226+
for (Option<?> option : optionsToCheck) {
227+
assertThat(actualOptions.getValue(option)).as(option.name()).isEqualTo(expectedOptions.getValue(option));
228+
}
229+
}
230+
231231
private enum ExpectedOption {
232232

233233
ACQUIRE_RETRY(PoolingConnectionFactoryProvider.ACQUIRE_RETRY, 4, "acquireRetry"),

0 commit comments

Comments
 (0)