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
15c44aa4
Commit
15c44aa4
authored
Nov 18, 2020
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.3.x'
Closes gh-24200
parents
57b053aa
988526be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
DataSourceUnwrapper.java
...va/org/springframework/boot/jdbc/DataSourceUnwrapper.java
+2
-2
DataSourceUnwrapperTests.java
...g/springframework/boot/jdbc/DataSourceUnwrapperTests.java
+11
-4
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceUnwrapper.java
View file @
15c44aa4
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -74,7 +74,7 @@ public final class DataSourceUnwrapper {
...
@@ -74,7 +74,7 @@ public final class DataSourceUnwrapper {
private
static
<
S
>
S
safeUnwrap
(
Wrapper
wrapper
,
Class
<
S
>
target
)
{
private
static
<
S
>
S
safeUnwrap
(
Wrapper
wrapper
,
Class
<
S
>
target
)
{
try
{
try
{
if
(
wrapper
.
isWrapperFor
(
target
))
{
if
(
target
.
isInterface
()
&&
wrapper
.
isWrapperFor
(
target
))
{
return
wrapper
.
unwrap
(
target
);
return
wrapper
.
unwrap
(
target
);
}
}
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/jdbc/DataSourceUnwrapperTests.java
View file @
15c44aa4
/*
/*
* Copyright 2012-20
19
the original author or authors.
* Copyright 2012-20
20
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
jdbc
;
package
org
.
springframework
.
boot
.
jdbc
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.util.function.Consumer
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
...
@@ -87,12 +88,18 @@ class DataSourceUnwrapperTests {
...
@@ -87,12 +88,18 @@ class DataSourceUnwrapperTests {
assertThat
(
DataSourceUnwrapper
.
unwrap
(
actual
,
DataSourceProxy
.
class
)).
isSameAs
(
dataSource
);
assertThat
(
DataSourceUnwrapper
.
unwrap
(
actual
,
DataSourceProxy
.
class
)).
isSameAs
(
dataSource
);
}
}
@Test
void
unwrappingIsNotAttemptedWhenTargetIsNotAnInterface
()
throws
SQLException
{
DataSource
dataSource
=
mock
(
DataSource
.
class
);
assertThat
(
DataSourceUnwrapper
.
unwrap
(
dataSource
,
HikariDataSource
.
class
)).
isNull
();
verifyNoMoreInteractions
(
dataSource
);
}
@Test
@Test
void
unwrappingIsNotAttemptedWhenDataSourceIsNotWrapperForTarget
()
throws
SQLException
{
void
unwrappingIsNotAttemptedWhenDataSourceIsNotWrapperForTarget
()
throws
SQLException
{
DataSource
dataSource
=
mock
(
DataSource
.
class
);
DataSource
dataSource
=
mock
(
DataSource
.
class
);
DataSource
actual
=
DataSourceUnwrapper
.
unwrap
(
dataSource
,
HikariDataSource
.
class
);
assertThat
(
DataSourceUnwrapper
.
unwrap
(
dataSource
,
Consumer
.
class
)).
isNull
();
assertThat
(
actual
).
isNull
();
verify
(
dataSource
).
isWrapperFor
(
Consumer
.
class
);
verify
(
dataSource
).
isWrapperFor
(
HikariDataSource
.
class
);
verifyNoMoreInteractions
(
dataSource
);
verifyNoMoreInteractions
(
dataSource
);
}
}
...
...
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