Skip to content

Commit e423f29

Browse files
committed
fixup
1 parent 311444a commit e423f29

File tree

4 files changed

+8
-6
lines changed

4 files changed

+8
-6
lines changed

src/jmh/java/io/r2dbc/postgresql/CopyInBenchmarks.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public class CopyInBenchmarks extends BenchmarkSettings {
6565
@State(Scope.Benchmark)
6666
public static class ConnectionHolder {
6767

68-
@Param({"1", "100", "1000000"})
68+
@Param({"0", "1", "100", "1000000"})
6969
int rows;
7070

7171
final PgConnection jdbc;

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

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
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;
2726
import io.r2dbc.postgresql.message.backend.ReadyForQuery;
2827
import io.r2dbc.postgresql.message.frontend.CopyData;
2928
import io.r2dbc.postgresql.message.frontend.CopyDone;
3029
import io.r2dbc.postgresql.message.frontend.CopyFail;
3130
import io.r2dbc.postgresql.message.frontend.FrontendMessage;
3231
import io.r2dbc.postgresql.message.frontend.Query;
3332
import io.r2dbc.postgresql.util.Assert;
33+
import io.r2dbc.postgresql.util.Operators;
3434
import org.reactivestreams.Publisher;
3535
import reactor.core.publisher.Flux;
3636
import reactor.core.publisher.Mono;
@@ -69,6 +69,7 @@ private Mono<Long> copyIn(String sql, Flux<FrontendMessage> frontendMessages) {
6969
return startCopy(sql)
7070
.concatWith(backendMessages)
7171
.doOnCancel(() -> sendCopyFail("Cancelled"))
72+
.as(Operators::discardOnCancel)
7273
.as(messages -> toResult(context, messages, ExceptionFactory.INSTANCE).getRowsUpdated());
7374
}
7475

@@ -80,13 +81,14 @@ private Flux<BackendMessage> startCopy(String sql) {
8081
)
8182
.doOnNext(message -> {
8283
if (message instanceof CommandComplete) {
83-
throw new IllegalArgumentException("Copy from stdin query expected but was ['" + sql + "']");
84+
throw new IllegalArgumentException("Copy from stdin query expected, sql='" + sql + "', message=" + message);
8485
}
8586
});
8687
}
8788

8889
private void sendCopyFail(String message) {
89-
context.getClient().exchange(m -> m instanceof CommandComplete || m instanceof ErrorResponse, Mono.just(new CopyFail("Copy operation failed: " + message)))
90+
context.getClient().exchange(Mono.just(new CopyFail("Copy operation failed: " + message)))
91+
.as(Operators::discardOnCancel)
9092
.subscribe();
9193
}
9294

src/test/java/io/r2dbc/postgresql/PostgresqlCopyInIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ void shouldHandleErrorOnValidNonCopyInQuery() {
118118
.as(StepVerifier::create)
119119
.consumeErrorWith(e -> assertThat(e)
120120
.isInstanceOf(IllegalArgumentException.class)
121-
.hasMessage("Copy from stdin query expected but was ['SELECT 1']")
121+
.hasMessage("Copy from stdin query expected, sql='SELECT 1', message=CommandComplete{command=SELECT, rowId=null, rows=1}")
122122
)
123123
.verify();
124124
}

src/test/java/io/r2dbc/postgresql/PostgresqlCopyInUnitTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ void copyInInvalidQuery() {
7979
.as(StepVerifier::create)
8080
.consumeErrorWith(e -> assertThat(e)
8181
.isInstanceOf(IllegalArgumentException.class)
82-
.hasMessage("Copy from stdin query expected but was ['" + sql + "']")
82+
.hasMessage("Copy from stdin query expected, sql='invalid-sql', message=CommandComplete{command=command, rowId=0, rows=9}")
8383
)
8484
.verify();
8585
}

0 commit comments

Comments
 (0)