Skip to content

Commit 0a5ed42

Browse files
committed
fix concurrent close
1 parent b57550f commit 0a5ed42

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/utils/FlightEndpointDataQueue.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ interface EndpointStreamSupplier {
9797

9898
private CloseableEndpointStreamPair next(final EndpointStreamSupplier endpointStreamSupplier)
9999
throws SQLException {
100-
checkOpen();
100+
// No checkOpen here: a concurrent close() is an end-of-stream signal for readers,
101+
// not an error. Cancelled in-flight streams still surface via future.get() below.
101102
while (!futures.isEmpty()) {
102103
final Future<CloseableEndpointStreamPair> future = endpointStreamSupplier.get();
103104
futures.remove(future);

flight/flight-sql-jdbc-core/src/test/java/org/apache/arrow/driver/jdbc/utils/FlightEndpointDataQueueTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,9 @@ public void testNextShouldRetrieveNullIfEmpty() throws Exception {
4848
}
4949

5050
@Test
51-
public void testNextShouldThrowExceptionUponClose() throws Exception {
51+
public void testNextShouldReturnNullUponClose() throws Exception {
5252
queue.close();
53-
ThrowableAssertionUtils.simpleAssertThrowableClass(
54-
IllegalStateException.class, () -> queue.next());
53+
assertThat(queue.next(), is(nullValue()));
5554
}
5655

5756
@Test

0 commit comments

Comments
 (0)