Skip to content

Commit eecd7d4

Browse files
committed
fix(batch): avoid Assertions.catch*
1 parent 9043ad8 commit eecd7d4

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

src/test/java/io/weaviate/client6/v1/api/collections/batch/BatchContextTest.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.junit.After;
2222
import org.junit.AfterClass;
2323
import org.junit.Before;
24+
import org.junit.Ignore;
2425
import org.junit.Test;
2526

2627
import io.grpc.stub.StreamObserver;
@@ -109,7 +110,7 @@ public void startContext() throws InterruptedException {
109110

110111
@After
111112
public void reset() throws Exception {
112-
if (context != null && !contextClosed) {
113+
if (!contextClosed) {
113114
closeContext();
114115
}
115116
context = null;
@@ -136,9 +137,13 @@ private void closeContext() throws Exception {
136137
throw new RuntimeException(e);
137138
}
138139
}, BACKGROUND).thenCompose(__ -> out.eof(true));
139-
context.close();
140-
eof.get();
141-
contextClosed = true;
140+
141+
try {
142+
context.close();
143+
eof.get();
144+
} finally {
145+
contextClosed = true;
146+
}
142147
}
143148

144149
@Test
@@ -418,15 +423,15 @@ public void test_maxReconnectRetries() throws Exception {
418423
}
419424

420425
out.hangup();
421-
Assertions.assertThat(in.done).completesExceptionallyWithin(5, TimeUnit.SECONDS);
422-
423-
Assertions.assertThatThrownBy(() -> context.close())
426+
427+
try {
428+
this.closeContext();
429+
}
430+
catch (Throwable t) {
431+
Assertions.assertThat(t)
424432
.isInstanceOf(IOException.class)
425433
.hasMessageContaining("Server unavailable");
426-
427-
// Cleanup: unset the context to prevent test teardown code
428-
// from tripping on it while trying to close the context.
429-
context = null;
434+
}
430435
}
431436

432437
@Test(expected = IllegalStateException.class)

0 commit comments

Comments
 (0)