Skip to content

Commit ed8c1e7

Browse files
Close stream in createStream example (#1051)
Each stream occupies memory in the database and needs to be closed to avoid a database out-of-memory error.
1 parent 1525ba1 commit ed8c1e7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

vertx-pg-client/src/main/java/examples/SqlClientExamples.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,12 @@ public void usingCursors03(SqlConnection connection) {
328328
System.out.println("Error: " + err.getMessage());
329329
});
330330
stream.endHandler(v -> {
331-
tx.commit();
332-
System.out.println("End of stream");
331+
// Close the stream to release the resources in the database
332+
stream.close(closed -> {
333+
tx.commit(committed -> {
334+
System.out.println("End of stream");
335+
});
336+
});
333337
});
334338
stream.handler(row -> {
335339
System.out.println("User: " + row.getString("last_name"));

0 commit comments

Comments
 (0)