Error handling problem
I've implemented a small application that connects to Postgres via this driver. I have only one method that triggers database and this method looks like that:
@Override
public Mono<User> findByEmail(final String email) {
try (final var session = dataSource.getSession()) {
final var future = session.<List<Result.RowColumn>>rowOperation("select * from users where email = $1")
.set("$1", email, AdbaType.VARCHAR)
.collect(Collectors.toList())
.submit()
.getCompletionStage()
.thenApply(rc -> toUser(rc.get(0)))
.toCompletableFuture();
return Mono.fromFuture(future);
}
}
I have a running instance of PG database and the underlying DB schema doesn't have a "users" table. So when I execute the code above I expect to receive some user-friendly message like "Table 'users' doesn't exist". Instead of this, the method hangs and return neither error nor null. I tried to wait a few minutes but it continues hanging without returning any result.
Could you please advise if it is a bug in my code or a bug in the driver itself? Thank you
UPD I use 0.1.0-ALPHA version of the library
Hi, thanks for testing it out.
Could you also show the connection url that you use (no username or password necessary) and i'll try to replicate the issue and find the bug tonight.
My configuration:
@Bean
public DataSource dataSource() {
return DataSourceFactory.newFactory("org.postgresql.adba.PgDataSourceFactory")
.builder()
.url("jdbc:postgresql://localhost:5432/webflux")
.username("postgres")
.password("postgres")
.build();
}
I tried to recreate your bug here https://github.com/alexanderkjall/pgadba-triage-bug28 without success.
I run that code with:
mvn clean package && java -jar target/gs-reactive-rest-service-0.1.0.jar
and access the function with:
curl localhost:8080/email
If I doesn't have a users table i get this response:
{"timestamp":"2018-11-20T18:08:19.881+0000","path":"/email","status":500,"error":"Internal Server Error","message":"jdk.incubator.sql2.SqlException: relation \"users\" does not exist"}
And with a users table with a user in it:
{"email":"test"}
Maybe the error is somewhere in the toUser function, could you make a pull request to the triage repository in order to reproduce the bug?
I will try again a little bit later. Will drop a message when I have a result.