Skip to content

query/queryStream/update handlers invoked again if they throw an exception #104

Closed
@omarsahl

Description

@omarsahl

The method below prints out "Successful insertion" and "Insertion failed".
Am I missing something or is it a normal behavior?

private void insert(Movie movie, SQLConnection connection, Handler<AsyncResult<Movie>> next) {
        String sql = "INSERT INTO Movies (name, release) VALUES (?, ?)";
        JsonArray json = new JsonArray().add(movie.getName()).add(movie.getRelease());

        connection.updateWithParams(
            sql,
            json,
            (asyncResult) -> {
                if (asyncResult.succeeded()) {
                    System.out.println("Successful insertion");
                }

                if (asyncResult.failed()) {
                    System.out.println("Insertion failed");
                    next.handle(Future.failedFuture(asyncResult.cause()));
                    return;
                }

                UpdateResult result = asyncResult.result();
                Movie m = new Movie(result.getKeys().getInteger(0), movie.getName(), movie.getRelease());
                next.handle(Future.succeededFuture(m));
            }
        );
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions