Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
faeda6f9
Commit
faeda6f9
authored
Jun 08, 2021
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
4c71e812
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
14 deletions
+12
-14
ConnectionFactoryBuilder.java
.../springframework/boot/r2dbc/ConnectionFactoryBuilder.java
+2
-4
ConnectionFactoryBuilderTests.java
...ngframework/boot/r2dbc/ConnectionFactoryBuilderTests.java
+10
-10
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilder.java
View file @
faeda6f9
...
...
@@ -221,10 +221,9 @@ public final class ConnectionFactoryBuilder {
String
[]
protocols
=
protocol
.
split
(
COLON
,
2
);
String
driverDelegate
=
protocols
[
0
];
String
protocolDelegate
=
(
protocols
.
length
!=
2
)
?
""
:
protocols
[
1
];
ConnectionFactoryOptions
newOptions
=
ConnectionFactoryOptions
.
builder
().
from
(
options
)
return
ConnectionFactoryOptions
.
builder
().
from
(
options
)
.
option
(
ConnectionFactoryOptions
.
DRIVER
,
driverDelegate
)
.
option
(
ConnectionFactoryOptions
.
PROTOCOL
,
protocolDelegate
).
build
();
return
newOptions
;
}
ConnectionPoolConfiguration
connectionPoolConfiguration
(
ConnectionFactoryOptions
options
,
...
...
@@ -253,8 +252,7 @@ public final class ConnectionFactoryBuilder {
map
.
from
(
options
.
getValue
(
PoolingConnectionFactoryProvider
.
VALIDATION_QUERY
)).
to
(
builder:
:
validationQuery
);
map
.
from
((
Object
)
options
.
getValue
(
PoolingConnectionFactoryProvider
.
VALIDATION_DEPTH
))
.
as
(
this
::
toValidationDepth
).
to
(
builder:
:
validationDepth
);
ConnectionPoolConfiguration
build
=
builder
.
build
();
return
build
;
return
builder
.
build
();
}
private
Integer
toInteger
(
Object
object
)
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/r2dbc/ConnectionFactoryBuilderTests.java
View file @
faeda6f9
...
...
@@ -188,7 +188,7 @@ class ConnectionFactoryBuilderTests {
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
@MethodSource
(
"poolingConnectionProviderOptions"
)
void
optionIsMappedWhenCreatingPoolConfiguration
(
Option
option
)
{
String
url
=
"r2dbc:pool:h2:mem:///"
+
UUID
.
randomUUID
()
.
toString
()
;
String
url
=
"r2dbc:pool:h2:mem:///"
+
UUID
.
randomUUID
();
ExpectedOption
expectedOption
=
ExpectedOption
.
get
(
option
);
ConnectionFactoryOptions
options
=
ConnectionFactoryBuilder
.
withUrl
(
url
).
configure
((
builder
)
->
builder
.
option
(
PoolingConnectionFactoryProvider
.
POOL_NAME
,
"defaultName"
).
option
(
option
,
expectedOption
.
value
))
...
...
@@ -202,7 +202,7 @@ class ConnectionFactoryBuilderTests {
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
@MethodSource
(
"poolingConnectionProviderOptions"
)
void
stringlyTypedOptionIsMappedWhenCreatingPoolConfiguration
(
Option
option
)
{
String
url
=
"r2dbc:pool:h2:mem:///"
+
UUID
.
randomUUID
()
.
toString
()
;
String
url
=
"r2dbc:pool:h2:mem:///"
+
UUID
.
randomUUID
();
ExpectedOption
expectedOption
=
ExpectedOption
.
get
(
option
);
ConnectionFactoryOptions
options
=
ConnectionFactoryBuilder
.
withUrl
(
url
)
.
configure
((
builder
)
->
builder
.
option
(
PoolingConnectionFactoryProvider
.
POOL_NAME
,
"defaultName"
)
...
...
@@ -213,21 +213,21 @@ class ConnectionFactoryBuilderTests {
assertThat
(
configuration
).
extracting
(
expectedOption
.
property
).
isEqualTo
(
expectedOption
.
value
);
}
private
void
assertMatchingOptions
(
ConnectionFactoryOptions
actualOptions
,
ConnectionFactoryOptions
expectedOptions
,
Option
<?>...
optionsToCheck
)
{
for
(
Option
<?>
option
:
optionsToCheck
)
{
assertThat
(
actualOptions
.
getValue
(
option
)).
as
(
option
.
name
()).
isEqualTo
(
expectedOptions
.
getValue
(
option
));
}
}
private
static
Iterable
<
Arguments
>
poolingConnectionProviderOptions
()
{
List
<
Arguments
>
arguments
=
new
ArrayList
<>();
ReflectionUtils
.
doWithFields
(
PoolingConnectionFactoryProvider
.
class
,
(
field
)
->
arguments
.
add
(
Arguments
.
of
(
(
Option
<?>)
ReflectionUtils
.
getField
(
field
,
null
))),
(
field
)
->
arguments
.
add
(
Arguments
.
of
(
ReflectionUtils
.
getField
(
field
,
null
))),
(
field
)
->
Option
.
class
.
equals
(
field
.
getType
()));
return
arguments
;
}
private
void
assertMatchingOptions
(
ConnectionFactoryOptions
actualOptions
,
ConnectionFactoryOptions
expectedOptions
,
Option
<?>...
optionsToCheck
)
{
for
(
Option
<?>
option
:
optionsToCheck
)
{
assertThat
(
actualOptions
.
getValue
(
option
)).
as
(
option
.
name
()).
isEqualTo
(
expectedOptions
.
getValue
(
option
));
}
}
private
enum
ExpectedOption
{
ACQUIRE_RETRY
(
PoolingConnectionFactoryProvider
.
ACQUIRE_RETRY
,
4
,
"acquireRetry"
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment