Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,28 @@ public String visit(String value) {
}
}

@Test
public void testCloseTwiceWithCatalogClosesSessionOnce() throws Exception {
final Properties properties = new Properties();
properties.put(ArrowFlightConnectionProperty.USER.camelName(), userTest);
properties.put(ArrowFlightConnectionProperty.PASSWORD.camelName(), passTest);
properties.put(ArrowFlightConnectionProperty.CATALOG.camelName(), "test_catalog");
properties.put("useEncryption", false);
final int closeSessionCountBefore = PRODUCER.getCloseSessionCount();

final Connection connection =
DriverManager.getConnection(
"jdbc:arrow-flight-sql://"
+ FLIGHT_SERVER_TEST_EXTENSION.getHost()
+ ":"
+ FLIGHT_SERVER_TEST_EXTENSION.getPort(),
properties);
connection.close();
connection.close();

assertEquals(closeSessionCountBefore + 1, PRODUCER.getCloseSessionCount());
}

@Test
public void testStatementsClosedOnConnectionClose() throws Exception {
// create a connection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,14 @@
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.stream.IntStream;
import org.apache.arrow.flight.Action;
import org.apache.arrow.flight.CallStatus;
import org.apache.arrow.flight.CloseSessionRequest;
import org.apache.arrow.flight.CloseSessionResult;
import org.apache.arrow.flight.Criteria;
import org.apache.arrow.flight.FlightDescriptor;
import org.apache.arrow.flight.FlightEndpoint;
Expand Down Expand Up @@ -758,6 +761,22 @@ public Map<String, SessionOptionValue> getSessionOptions() {
return sessionOptions;
}

private final AtomicInteger closeSessionCount = new AtomicInteger();

@Override
public void closeSession(
final CloseSessionRequest request,
final CallContext context,
final StreamListener<CloseSessionResult> listener) {
closeSessionCount.incrementAndGet();
listener.onNext(new CloseSessionResult(CloseSessionResult.Status.CLOSED));
listener.onCompleted();
}

public int getCloseSessionCount() {
return closeSessionCount.get();
}

private static final class TicketConversionUtils {
private TicketConversionUtils() {
// Prevent instantiation.
Expand Down
Loading