Skip to content

Commit

Permalink
fixing RestIndexAction
Browse files Browse the repository at this point in the history
  • Loading branch information
masseyke committed Jan 2, 2024
1 parent 097312f commit a270429
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

package org.elasticsearch.rest.action.document;

import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.DocWriteRequest;
import org.elasticsearch.action.DocWriteResponse;
import org.elasticsearch.action.index.IndexRequest;
Expand Down Expand Up @@ -145,10 +146,14 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC

return channel -> client.index(
indexRequest,
new RestToXContentListener<>(channel, DocWriteResponse::status, r -> r.getLocation(indexRequest.routing()))
ActionListener.runAfter(
new RestToXContentListener<>(channel, DocWriteResponse::status, r -> r.getLocation(indexRequest.routing())),
indexRequest::decRef
)
);
} finally {
} catch (Exception e) {
indexRequest.decRef();
throw e;
}
}

Expand Down

0 comments on commit a270429

Please sign in to comment.