Skip to content

Commit 564cbee

Browse files
authored
Fix JVM deoptimization loop due to lambda misprediction (opensearch-project#20832)
--------- Signed-off-by: Christopher Peck <peck@uber.com>
1 parent 6e92a76 commit 564cbee

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/main/java/org/opensearch/action/bulk/BulkItemRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,9 @@ public void writeTo(StreamOutput out) throws IOException {
139139
public void writeThin(StreamOutput out) throws IOException {
140140
out.writeVInt(id);
141141
DocWriteRequest.writeDocumentRequestThin(out, request);
142-
out.writeOptionalWriteable(primaryResponse == null ? null : primaryResponse::writeThin);
142+
143+
BulkItemResponse primaryResponse = this.primaryResponse; // Read volatile once
144+
out.writeOptionalWriteable((o, resp) -> resp.writeThin(o), primaryResponse);
143145
}
144146

145147
@Override

0 commit comments

Comments
 (0)