avantgardnerio commented on code in PR #13900:
URL: https://github.com/apache/arrow/pull/13900#discussion_r947178000


##########
java/flight/flight-jdbc-driver/src/main/java/org/apache/arrow/driver/jdbc/client/ArrowFlightSqlClientHandler.java:
##########
@@ -92,11 +103,16 @@ private CallOption[] getOptions() {
    * @param flightInfo The {@link FlightInfo} instance from which to fetch 
results.
    * @return a {@code FlightStream} of results.
    */
-  public List<FlightStream> getStreams(final FlightInfo flightInfo) {
-    return flightInfo.getEndpoints().stream()
-        .map(FlightEndpoint::getTicket)
-        .map(ticket -> sqlClient.getStream(ticket, getOptions()))
-        .collect(Collectors.toList());
+  public List<FlightStream> getStreams(final FlightInfo flightInfo) throws 
SQLException {
+      ArrayList<org.apache.arrow.flight.FlightStream> streams = new 
java.util.ArrayList<>();
+      for (FlightEndpoint ep : flightInfo.getEndpoints()) {
+        URI uri = ep.getLocations().isEmpty() ? null : 
ep.getLocations().get(0).getUri();
+        FlightSqlClient sqlClient = this.factory.createConnection(uri);
+        FlightStream stream = sqlClient.getStream(ep.getTicket(), 
getOptions());
+        FlightClientCloser closer = new FlightClientCloser(sqlClient, stream);

Review Comment:
   Wrap the stream to ensure it gets closed.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to