Skip to content

Commit 1fcb8d3

Browse files
gavinkingSanne
authored andcommitted
add SessionFactory.close()
to clean up Vert.x and its Pool
1 parent 9b759be commit 1fcb8d3

File tree

7 files changed

+21
-3
lines changed

7 files changed

+21
-3
lines changed

example/src/main/java/org/hibernate/example/reactive/Main.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public static void main(String[] args) {
7979
)
8080
.toCompletableFuture().join();
8181

82-
System.exit(0);
82+
sessionFactory.close();
8383
}
8484

8585
}

example/src/main/java/org/hibernate/example/reactive/MutinyMain.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public static void main(String[] args) {
7878
)
7979
.await().indefinitely();
8080

81-
System.exit(0);
81+
sessionFactory.close();
8282
}
8383

8484
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/Mutiny.java

+5
Original file line numberDiff line numberDiff line change
@@ -595,5 +595,10 @@ interface SessionFactory {
595595
*/
596596
<T> Uni<T> withReactiveSession(Function<Session, Uni<T>> work);
597597

598+
/**
599+
* Destroy the session factory and clean up its connection
600+
* pool.
601+
*/
602+
void close();
598603
}
599604
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/mutiny/impl/MutinySessionFactoryImpl.java

+4
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ public <T> Uni<T> withReactiveSession(Function<Mutiny.Session, Uni<T>> work) {
3939
);
4040
}
4141

42+
@Override
43+
public void close() {
44+
delegate.close();
45+
}
4246
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/Stage.java

+5
Original file line numberDiff line numberDiff line change
@@ -595,5 +595,10 @@ interface SessionFactory {
595595
*/
596596
<T> CompletionStage<T> withReactiveSession(Function<Session, CompletionStage<T>> work);
597597

598+
/**
599+
* Destroy the session factory and clean up its connection
600+
* pool.
601+
*/
602+
void close();
598603
}
599604
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/stage/impl/StageSessionFactoryImpl.java

+4
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@ public <T> CompletionStage<T> withReactiveSession(Function<Stage.Session, Comple
4040
);
4141
}
4242

43+
@Override
44+
public void close() {
45+
delegate.close();
46+
}
4347
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/vertx/impl/ProvidedVertxInstance.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* An implementation of {@link VertxInstance} which allows the client
1010
* to provide an instance of {@link Vertx} whose lifecyle is managed
11-
* extrenally to Hibernate Reactive. The {@code ProvidedVertxInstance}
11+
* externally to Hibernate Reactive. The {@code ProvidedVertxInstance}
1212
* must be registered with explicitly Hibernate by calling
1313
* {@link org.hibernate.boot.registry.StandardServiceRegistryBuilder#addService}.
1414
* Hibernate will destroy the {@code Vertx} instance on shutdown.

0 commit comments

Comments
 (0)