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

ElasticsearchAsyncClient no return #927

Closed
Swiftlyfisher opened this issue Jan 23, 2025 · 1 comment
Closed

ElasticsearchAsyncClient no return #927

Swiftlyfisher opened this issue Jan 23, 2025 · 1 comment
Labels
Category: Not an issue This doesn't seem right

Comments

@Swiftlyfisher
Copy link

Elasticsearch Version

java client 8.17.0

Installed Plugins

No response

Java Version

21

OS Version

win10

Problem Description

esClient.indices()
.create(b -> b.index(index).withJson(json))
.whenComplete((r, e) -> {
if (e != null) Log.error("[EsQuery]: create index $index failed", e);
Log.info("[EsQuery]: create index $index success");
}

As above, if I pass in a syntax incorrect JSON, whenComplete will not be executed.

Steps to Reproduce

esClient.indices()
.create(b -> b.index(index).withJson(json))
.whenComplete((r, e) -> {
if (e != null) Log.error("[EsQuery]: create index $index failed", e);
Log.info("[EsQuery]: create index $index success");
}

As above, if I pass in a syntax incorrect JSON, whenComplete will not be executed.

Logs (if relevant)

No response

@gbanasiak gbanasiak transferred this issue from elastic/elasticsearch Jan 23, 2025
@l-trotta
Copy link
Contributor

Hello, this is a normal behavior: if an incorrect json is passed to the withJson() method, it will throw a parsing exception (details depending on the json mapper that has been configured); thus, the code will never reach whenComplete(). A try catch clause should be used to handle this kind of situations.

@l-trotta l-trotta added the Category: Not an issue This doesn't seem right label Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Not an issue This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants