File tree Expand file tree Collapse file tree 1 file changed +33
-1
lines changed
src/main/java/com/influxdb/v3/client/internal Expand file tree Collapse file tree 1 file changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -270,11 +270,43 @@ public VectorSchemaRoot next() {
270270
271271 @ Override
272272 public void close () {
273+ Exception pendingException = null ;
274+
275+ // Try to close FlightStream
273276 try {
274277 flightStream .close ();
278+ } catch (Exception e ) {
279+ LOG .warn ("FlightStream close failed: {}" , e .toString ());
280+ pendingException = e ;
281+
282+ // Retry close - first attempt drained stream but threw exception before cleanup,
283+ // retry finds stream already drained and completes cleanup successfully
284+ try {
285+ flightStream .close ();
286+ // Retry succeeded - clear the exception
287+ pendingException = null ;
288+ } catch (Exception retryException ) {
289+ // Retry also failed - keep original exception
290+ // but continue to close collected Arrow resources anyway
291+ LOG .error ("FlightStream close failed even after retry attempt" , retryException );
292+ }
293+ }
294+
295+ // ALWAYS try to close collected Arrow resources
296+ try {
275297 AutoCloseables .close (autoCloseable );
276298 } catch (Exception e ) {
277- throw new RuntimeException (e );
299+ LOG .error ("AutoCloseable close failed" , e );
300+ if (pendingException != null ) {
301+ pendingException .addSuppressed (e );
302+ } else {
303+ pendingException = e ;
304+ }
305+ }
306+
307+ // Throw pending exceptions
308+ if (pendingException != null ) {
309+ throw new RuntimeException (pendingException );
278310 }
279311 }
280312 }
You can’t perform that action at this time.
0 commit comments