Skip to content

Commit 91ab11c

Browse files
committed
Deadlock with shutdown fix #589
1 parent d984d0e commit 91ab11c

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

jooby-ebean/src/main/java/org/jooby/ebean/Ebeanby.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ public class Ebeanby extends Jdbc {
149149

150150
private Set<String> packages = new HashSet<>();
151151

152+
static {
153+
// Turn off ebean shutdown hook:
154+
System.setProperty("ebean.registerShutdownHook", "false");
155+
}
156+
152157
/**
153158
* Creates a new {@link Ebeanby} using the given name to setup a {@link Jdbc} datasource.
154159
*
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.jooby.ebean;
2+
3+
import static org.easymock.EasyMock.expect;
4+
5+
import org.jooby.test.MockUnit;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
import org.powermock.core.classloader.annotations.PrepareForTest;
9+
import org.powermock.modules.junit4.PowerMockRunner;
10+
11+
@RunWith(PowerMockRunner.class)
12+
@PrepareForTest({Ebeanby.class, System.class })
13+
public class Issue589 {
14+
15+
@Test
16+
public void shouldTurnOffEbeanShutdownHook() throws Exception {
17+
new MockUnit()
18+
.expect(unit -> {
19+
unit.mockStatic(System.class);
20+
expect(System.setProperty("ebean.registerShutdownHook", "false")).andReturn(null);
21+
})
22+
.run(unit -> {
23+
new Ebeanby();
24+
});
25+
}
26+
27+
}

0 commit comments

Comments
 (0)