Skip to content

Commit 413bbb9

Browse files
committed
feat(batch): do not interrupt the parent thread if the context is being closed already
1 parent 0477638 commit 413bbb9

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/main/java/io/weaviate/client6/v1/api/collections/batch/BatchContext.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ private void shutdown() {
294294
}
295295

296296
private void shutdownNow(Exception ex) {
297-
// Now report this error to the server and close the stream.
297+
// Now report this error to the server and terminate the stream.
298298
closing.completeExceptionally(ex);
299299
messages.onError(Status.INTERNAL.withCause(ex).asRuntimeException());
300300

@@ -307,10 +307,12 @@ private void shutdownNow(Exception ex) {
307307
} catch (Exception e) {
308308
}
309309

310-
// Since shutdownNow is never triggered by the "main" thread,
311-
// it may be blocked on trying to add to the queue. While batch
312-
// context is active, we own this thread and may interrupt it.
313-
parent.interrupt();
310+
if (!closed) {
311+
// Since shutdownNow is never triggered by the "main" thread,
312+
// it may be blocked on trying to add to the queue. While batch
313+
// context is active, we own this thread and may interrupt it.
314+
parent.interrupt();
315+
}
314316
}
315317

316318
private void shutdownExecutors() {

0 commit comments

Comments
 (0)