Skip to content

Commit 96e5f5b

Browse files
committed
fix: add fix
1 parent a1df23d commit 96e5f5b

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/main/java/com/influxdb/v3/client/internal/FlightSqlClient.java

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)