Skip to content

NPE in ElasticsearchExceptionTranslator #2388

Closed
@ztomic

Description

@ztomic

Hi,

I'm migrating from Spring Boot 2.7 to Spring Boot 3 and switching to new Spring Data Elasticsearch.

I have many problems with it (most of them with rewriting queries and aggregations from old to new Spring Data - since QueryBuilders class from here is missing queries, I must mix it with QueryBuilders from ES client and direct builders for query/aggregations from ES client - it is not the happiest solution that the QueryBuilders class in Spring Data Elasticsearch is named the same as in the ES client, and at many places I need to use ._toQuery() from QueryVariant)

Back to the topic, ElasticsearchExceptionTranslator is generating NullPointerException because ErrorResponse.error().type() is null:
image

image

Caused by: java.lang.NullPointerException: Cannot invoke "String.contains(java.lang.CharSequence)" because the return value of "co.elastic.clients.elasticsearch._types.ErrorCause.type()" is null
	at org.springframework.data.elasticsearch.client.elc.ElasticsearchExceptionTranslator.translateExceptionIfPossible(ElasticsearchExceptionTranslator.java:91)
	at org.springframework.data.elasticsearch.client.elc.ElasticsearchExceptionTranslator.translateException(ElasticsearchExceptionTranslator.java:62)
	at org.springframework.data.elasticsearch.client.elc.ChildTemplate.execute(ChildTemplate.java:73)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions