Skip to content

Commit 24d1035

Browse files
l-trottagithub-actions[bot]
authored andcommitted
avoid concurrent access to multibuffer entity iterator (#1016) (#1028)
1 parent 37f9b21 commit 24d1035

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

java-client/src/main/java/co/elastic/clients/transport/rest_client/MultiBufferEntity.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,13 @@ public void close() throws IOException {
6060
}
6161

6262
private void init() {
63-
this.iterator = buffers.iterator();
64-
if (this.iterator.hasNext()) {
65-
this.currentBuffer = this.iterator.next().duplicate();
63+
Iterator<ByteBuffer> localIterator = this.buffers.iterator();
64+
if (localIterator.hasNext()) {
65+
this.currentBuffer = localIterator.next().duplicate();
6666
} else {
6767
this.currentBuffer = null;
6868
}
69+
this.iterator = localIterator;
6970
}
7071

7172
@Override

0 commit comments

Comments
 (0)