File tree Expand file tree Collapse file tree 1 file changed +5
-27
lines changed
ebean-datasource/src/test/java/io/ebean/datasource/pool Expand file tree Collapse file tree 1 file changed +5
-27
lines changed Original file line number Diff line number Diff line change 1515
1616public class ConnectionPoolRecoverTest {
1717
18- private int success ;
19- private int failure ;
20-
2118 @ Test
2219 void testHeavyLoadPool () throws Exception {
2320 DataSourcePool pool = DataSourceBuilder .create ()
@@ -31,35 +28,16 @@ void testHeavyLoadPool() throws Exception {
3128 // .heartbeatMaxPoolExhaustedCount(1)
3229 .failOnStart (false )
3330 .build ();
34- ExecutorService executorService = Executors .newCachedThreadPool ();
3531 try {
36- List <Future <?>> futures = new ArrayList <>();
37- for (int i = 0 ; i < 2 ; i ++) {
38- futures .add (executorService .submit (() -> doSomeWork (pool )));
39- }
40-
41- for (Future <?> future : futures ) {
42- future .get ();
32+ for (int i = 0 ; i < 5 ; i ++) {
33+ try (Connection conn = pool .getConnection ()) {
34+ Thread .sleep (2000 );
35+ conn .rollback ();
36+ }
4337 }
44- assertThat (success ).isGreaterThan (1 );
4538 } finally {
46- executorService .shutdownNow ();
4739 pool .shutdown ();
4840 }
49-
50- }
51-
52- private void doSomeWork (DataSourcePool pool ) {
53- for (int i = 0 ; i < 20 ; i ++) {
54- System .out .println ("Success: " + success + " failure: " + failure );
55- try (Connection conn = pool .getConnection ()) {
56- Thread .sleep (2000 );
57- success ++;
58- } catch (Exception e ) {
59- // nop
60- failure ++;
61- }
62- }
6341 }
6442
6543}
You can’t perform that action at this time.
0 commit comments