11package io .weaviate .client6 .v1 .api .collections .batch ;
22
3+ import java .io .IOException ;
34import java .util .ArrayList ;
45import java .util .Arrays ;
56import java .util .Collections ;
@@ -49,7 +50,7 @@ public class BatchContextTest {
4950 * which "survives" reconnects. The test code can listen on the same stream
5051 * even if the batch client re-creates it.
5152 */
52- private static final BlockingQueue <WeaviateProtoBatch .BatchStreamRequest > REQUEST_QUEUE = new ArrayBlockingQueue <>(1 );
53+ private final BlockingQueue <WeaviateProtoBatch .BatchStreamRequest > REQUEST_QUEUE = new ArrayBlockingQueue <>(1 );
5354
5455 /**
5556 * Dedicated executor for occasional asynchrony.
@@ -70,10 +71,15 @@ public class BatchContextTest {
7071 */
7172 private ExecutorService eventThread ;
7273
73- /** Batch context for the current test case. */
74- private BatchContext <Map <String , Object >> context ;
74+ /**
75+ * Batch context for the current test case.
76+ * Only {@link #startContext()} should assign to context.
77+ */
78+ private volatile BatchContext <Map <String , Object >> context ;
79+
7580 /** Track if the context has already been closed inside of the test. */
7681 private boolean contextClosed ;
82+
7783 /** Server half of the stream. */
7884 private volatile OutboundStream out ;
7985 /** Client half of the stream. */
@@ -422,14 +428,12 @@ public void test_maxReconnectRetries() throws Exception {
422428 }
423429
424430 out .hangup ();
431+ Assertions .assertThat (in .done )
432+ .completesExceptionallyWithin (5 , TimeUnit .SECONDS );
425433
426- try {
427- closeContext ();
428- } catch (Throwable t ) {
429- // Assertions.assertThat(t)
430- // .isInstanceOf(IOException.class)
431- // .hasMessageContaining("Server unavailable");
432- }
434+ Assertions .assertThatThrownBy (this ::closeContext )
435+ .isInstanceOf (IOException .class )
436+ .hasMessageContaining ("Server unavailable" );
433437 }
434438
435439 @ Test (expected = IllegalStateException .class )
0 commit comments