Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Db examples should use reactive approach (including template for CLI) #2697

Closed
tomas-langer opened this issue Jan 27, 2021 · 0 comments · Fixed by #2701
Closed

Db examples should use reactive approach (including template for CLI) #2697

tomas-langer opened this issue Jan 27, 2021 · 0 comments · Fixed by #2701
Assignees
Labels
2.x Issues for 2.x version branch DB client Helidon DB Client P2
Milestone

Comments

@tomas-langer
Copy link
Member

Current code:

try {
            List<PokemonType> pokemonTypes =
                    dbClient.execute(exec -> exec.namedQuery("select-all-types"))
                            .map(row -> row.as(PokemonType.class)).collectList().get();
            response.send(pokemonTypes);
        } catch (InterruptedException | ExecutionException e) {
            throw new RuntimeException(e);
        }

Correct code:

dbClient.execute(exec -> exec.namedQuery("select-all-types"))
                .map(row -> row.as(PokemonType.class))
                .collectList()
                .forSingle(response::send);

This is valid for other methods as well - we should never ever call .get on a completable future or await on Single or Multi in a routing method of web server

@tomas-langer tomas-langer added 2.x Issues for 2.x version branch DB client Helidon DB Client labels Jan 27, 2021
@tomas-langer tomas-langer added this to the 2.2.1 milestone Jan 27, 2021
@Tomas-Kraus Tomas-Kraus self-assigned this Jan 27, 2021
@Tomas-Kraus Tomas-Kraus linked a pull request Jan 28, 2021 that will close this issue
@m0mus m0mus added the P2 label Jan 28, 2021
@m0mus m0mus added this to Backlog Aug 12, 2024
@m0mus m0mus moved this to Closed in Backlog Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x Issues for 2.x version branch DB client Helidon DB Client P2
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants