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
35ad5cd0
Commit
35ad5cd0
authored
Sep 13, 2019
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix intermittent failure of inMemoryDerbyIsShutdown
parent
419f92d3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
1 deletion
+18
-1
DevToolsPooledDataSourceAutoConfigurationTests.java
...igure/DevToolsPooledDataSourceAutoConfigurationTests.java
+18
-1
No files found.
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/DevToolsPooledDataSourceAutoConfigurationTests.java
View file @
35ad5cd0
...
@@ -22,6 +22,8 @@ import java.util.Properties;
...
@@ -22,6 +22,8 @@ import java.util.Properties;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
com.zaxxer.hikari.HikariDataSource
;
import
com.zaxxer.hikari.HikariPoolMXBean
;
import
org.apache.derby.jdbc.EmbeddedDriver
;
import
org.apache.derby.jdbc.EmbeddedDriver
;
import
org.junit.After
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
...
@@ -122,8 +124,23 @@ public class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevT
...
@@ -122,8 +124,23 @@ public class DevToolsPooledDataSourceAutoConfigurationTests extends AbstractDevT
ConfigurableApplicationContext
context
=
createContext
(
"org.apache.derby.jdbc.EmbeddedDriver"
,
ConfigurableApplicationContext
context
=
createContext
(
"org.apache.derby.jdbc.EmbeddedDriver"
,
"jdbc:derby:memory:test;create=true"
,
DataSourceAutoConfiguration
.
class
,
"jdbc:derby:memory:test;create=true"
,
DataSourceAutoConfiguration
.
class
,
DataSourceSpyConfiguration
.
class
);
DataSourceSpyConfiguration
.
class
);
JdbcTemplate
jdbc
=
new
JdbcTemplate
(
context
.
getBean
(
DataSource
.
class
));
HikariDataSource
dataSource
=
context
.
getBean
(
HikariDataSource
.
class
);
JdbcTemplate
jdbc
=
new
JdbcTemplate
(
dataSource
);
jdbc
.
execute
(
"SELECT 1 FROM SYSIBM.SYSDUMMY1"
);
jdbc
.
execute
(
"SELECT 1 FROM SYSIBM.SYSDUMMY1"
);
HikariPoolMXBean
pool
=
dataSource
.
getHikariPoolMXBean
();
// Prevent a race between Hikari's initialization and Derby shutdown
long
end
=
System
.
currentTimeMillis
()
+
30000
;
while
(
pool
.
getIdleConnections
()
!=
dataSource
.
getMinimumIdle
())
{
if
(
System
.
currentTimeMillis
()
>=
end
)
{
throw
new
IllegalStateException
(
"DataSource did not become idle within 30 seconds"
);
}
try
{
Thread
.
sleep
(
100
);
}
catch
(
InterruptedException
ex
)
{
Thread
.
currentThread
().
interrupt
();
}
}
context
.
close
();
context
.
close
();
// Connect should fail as DB no longer exists
// Connect should fail as DB no longer exists
assertThatExceptionOfType
(
SQLException
.
class
)
assertThatExceptionOfType
(
SQLException
.
class
)
...
...
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