Skip to content

Commit eff6fde

Browse files
Daemonize event loop threads. (#918)
This instructs the `EventLoopGroupFactory` to daemonize newly created event loop group threads as per Netty's `DefaultThreadFactory`. This allows applications to shutdown when the last user thread ends, without explicitly calling `close` to the Neo4j driver instance, which is in line with other database drivers such as Postgres JDBC or MySQL JDBC. In addition, this might become relevant with Netty 5 at some point in the future, too. See: netty/netty#2832.
1 parent 27a8e96 commit eff6fde

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

driver/src/main/java/org/neo4j/driver/internal/async/connection/EventLoopGroupFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public final class EventLoopGroupFactory
4040
{
4141
private static final String THREAD_NAME_PREFIX = "Neo4jDriverIO";
4242
private static final int THREAD_PRIORITY = Thread.MAX_PRIORITY;
43+
private static final boolean THREAD_IS_DAEMON = true;
4344

4445
private EventLoopGroupFactory()
4546
{
@@ -127,7 +128,7 @@ private static class DriverThreadFactory extends DefaultThreadFactory
127128
{
128129
DriverThreadFactory()
129130
{
130-
super( THREAD_NAME_PREFIX, THREAD_PRIORITY );
131+
super( THREAD_NAME_PREFIX, THREAD_IS_DAEMON, THREAD_PRIORITY );
131132
}
132133

133134
@Override

0 commit comments

Comments
 (0)