Skip to content

Commit

Permalink
fix response close for getRowsUpdated(ClickHouse#1538)
Browse files Browse the repository at this point in the history
  • Loading branch information
wooEnrico committed Jan 30, 2024
1 parent bbd6808 commit f9851e7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,18 @@ public class ClickHouseResult implements Result {
.map(rec -> ClickHousePair.of(resp.getColumns(), rec))))
.map(pair -> new ClickHouseRow(pair.getRight(), pair.getLeft()))
.map(RowSegment::new);
this.updatedCount = Mono.just(response).map(ClickHouseResponse::getSummary)
.map(ClickHouseResponseSummary::getProgress)
.map(ClickHouseResponseSummary.Progress::getWrittenRows)
.map(UpdateCount::new);

this.updatedCount = Mono.using(() -> response,
resp -> Mono.just(response).map(ClickHouseResponse::getSummary)
.map(ClickHouseResponseSummary::getProgress)
.map(ClickHouseResponseSummary.Progress::getWrittenRows)
.map(UpdateCount::new),
resp -> {
if (!resp.isClosed()) {
resp.close();
}
});

this.segments = Flux.concat(this.updatedCount, this.rowSegments);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,16 @@ class ClickHouseResult implements Result {
.map(rec -> ClickHousePair.of(resp.getColumns(), rec))))
.map(pair -> new ClickHouseRow(pair.getRight(), pair.getLeft()))
.map(RowSegment::new);
this.updatedCount = Mono.just(response).map(ClickHouseResponse::getSummary)
.map(ClickHouseResponseSummary::getProgress)
.map(ClickHouseResponseSummary.Progress::getWrittenRows)
.map(UpdateCount::new);
this.updatedCount = Mono.using(() -> response,
resp -> Mono.just(response).map(ClickHouseResponse::getSummary)
.map(ClickHouseResponseSummary::getProgress)
.map(ClickHouseResponseSummary.Progress::getWrittenRows)
.map(UpdateCount::new),
resp -> {
if (!resp.isClosed()) {
resp.close();
}
});
this.segments = Flux.concat(this.updatedCount, this.rowSegments);
}

Expand Down

0 comments on commit f9851e7

Please sign in to comment.