Skip to content

Commit d743089

Browse files
committed
chore(batch): fix javadoc
1 parent a863655 commit d743089

1 file changed

Lines changed: 13 additions & 14 deletions

File tree

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

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
* re-throw the causing exception as {@link IOException}. The stream can be
112112
* terminated at any time, including during a graceful shutdown.
113113
* In case the context if terminated <i>before</i> a graceful shutdown begins,
114-
* the parent thread is also interrupted to prevent {@link #add()} from blocking
114+
* the parent thread is also interrupted to prevent {@link #add} from blocking
115115
* indefinitely, "sender" will not be there to pop items from the task queue).
116116
*
117117
* <p>
@@ -122,7 +122,7 @@
122122
*
123123
* @see StreamObserver
124124
* @see State
125-
* @see shutdownNow
125+
* @see #shutdownNow
126126
* @see TaskHandle#result()
127127
*
128128
* @author Dyma Solovei
@@ -294,6 +294,13 @@ void start() {
294294
* is reached.
295295
*/
296296
void reconnect() throws InterruptedException, ExecutionException {
297+
// We do not need to wait for the current latch to be "opened".
298+
// The "sender" survives reconnects and will not call countDown
299+
// until it's interrupted or the context is closed.
300+
// The "recv" thread is guaranteed to have already exited, because
301+
// the context can only transition into the Reconnecting state
302+
// after the server half of the stream is closed (EOF or hangup).
303+
assert workers.getCount() == 1 : "recv must exit before reconnect";
297304
workers = new CountDownLatch(2);
298305

299306
messages = streamFactory.createStream(new Recv());
@@ -620,23 +627,15 @@ public void onNext(Event event) {
620627
*/
621628
@Override
622629
public void onCompleted() {
623-
try {
624-
onEvent(Event.EOF);
625-
} finally {
626-
System.out.println("recv countDown (onCompleted)");
627-
workers.countDown();
628-
}
630+
workers.countDown();
631+
onEvent(Event.EOF);
629632
}
630633

631634
/** An exception occurred either on our end or in the channel internals. */
632635
@Override
633636
public void onError(Throwable t) {
634-
try {
635-
onEvent(Event.StreamHangup.fromThrowable(t));
636-
} finally {
637-
System.out.println("recv countDown (onError)");
638-
workers.countDown();
639-
}
637+
workers.countDown();
638+
onEvent(Event.StreamHangup.fromThrowable(t));
640639
}
641640
}
642641

0 commit comments

Comments
 (0)