Skip to content

Commit aa8983d

Browse files
committed
fix: cancel is called when testing with the GNS.
1 parent 0db9a7b commit aa8983d

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/io/r2dbc/postgresql/PostgresqlCopyIn.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import io.r2dbc.postgresql.message.backend.BackendMessage;
2424
import io.r2dbc.postgresql.message.backend.CommandComplete;
2525
import io.r2dbc.postgresql.message.backend.CopyInResponse;
26+
import io.r2dbc.postgresql.message.backend.ErrorResponse;
2627
import io.r2dbc.postgresql.message.backend.ReadyForQuery;
2728
import io.r2dbc.postgresql.message.frontend.CopyData;
2829
import io.r2dbc.postgresql.message.frontend.CopyDone;
@@ -67,9 +68,7 @@ private Mono<Long> copyIn(String sql, Flux<FrontendMessage> frontendMessages) {
6768

6869
return startCopy(sql)
6970
.concatWith(backendMessages)
70-
.doOnCancel(() -> {
71-
sendCopyFail("Cancelled");
72-
})
71+
.doOnCancel(() -> sendCopyFail("Cancelled"))
7372
.as(messages -> toResult(context, messages, ExceptionFactory.INSTANCE).getRowsUpdated());
7473
}
7574

@@ -87,7 +86,7 @@ private Flux<BackendMessage> startCopy(String sql) {
8786
}
8887

8988
private void sendCopyFail(String message) {
90-
context.getClient().exchange(m -> m instanceof CommandComplete, Mono.just(new CopyFail("Copy operation failed: " + message)))
89+
context.getClient().exchange(m -> m instanceof CommandComplete || m instanceof ErrorResponse, Mono.just(new CopyFail("Copy operation failed: " + message)))
9190
.subscribe();
9291
}
9392

0 commit comments

Comments
 (0)