Andrea Cosentino created CAMEL-24816:
----------------------------------------

             Summary: camel-elasticsearch/camel-opensearch: minor robustness 
fixes (scroll clear NPE, id header clobber, size/from header bleed)
                 Key: CAMEL-24816
                 URL: https://issues.apache.org/jira/browse/CAMEL-24816
             Project: Camel
          Issue Type: Bug
          Components: camel-elasticsearch, camel-opensearch
            Reporter: Andrea Cosentino
            Assignee: Andrea Cosentino


Three small, related robustness issues shared by camel-elasticsearch and 
camel-opensearch:

*1. Scroll clear can NPE on a null scroll id.* 
{{(Elasticsearch|Opensearch)ScrollRequestIterator.close()}} builds {{new 
ClearScrollRequest.Builder().scrollId(List.of(scrollId))}}. If the search 
response carried no scroll id (empty/absent), {{scrollId}} is null and 
{{List.of(null)}} throws NullPointerException from {{close()}}, masking the 
real outcome. Guard: only issue the clear-scroll when a scroll id is present.

*2. A null index-id header clobbers a caller-supplied id.* In 
{{(Elasticsearch|Opensearch)ActionRequestConverter}}, when the body is already 
a pre-built {{IndexRequest.Builder}}/{{UpdateRequest.Builder}}, the converter 
calls {{.id(getHeader(PARAM_INDEX_ID))}} unconditionally. If the caller built 
the request with an id but did not set the {{CamelIndexId}} header, the id is 
overwritten with null. Guard: only set the id when the header is present. 
(Also: camel-elasticsearch used reference-equality {{enableDocumentOnlyMode == 
Boolean.TRUE}}; switch to {{Boolean.TRUE.equals(...)}}.)

*3. size/from headers bleed downstream.* The producer defaults 
{{CamelElasticsearchSize}}/{{...From}} (and OpenSearch equivalents) from the 
endpoint configuration when absent, but {{cleanup()}} removes only the 
index-name and wait-for-active-shards headers. The defaulted size/from headers 
therefore persist on the exchange and leak into a subsequent endpoint. Remove 
them in {{cleanup()}} exactly as the other defaulted headers are removed.

Adds a converter unit test (both components) for the id-header guard. Backport 
candidate for camel-4.22.x and camel-4.18.x.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to