changeset 546:eb7ecfbb48f2 onclient

Never forget to close the download handle
author Joeri van Ruth <joeri.van.ruth@monetdbsolutions.com>
date Tue, 14 Sep 2021 09:22:16 +0200 (2021-09-14)
parents 79393647d7fb
children 8029d7368b5a
files src/main/java/org/monetdb/jdbc/MonetConnection.java
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.java
+++ b/src/main/java/org/monetdb/jdbc/MonetConnection.java
@@ -3256,13 +3256,16 @@ public class MonetConnection
 		}
 
 		Download handle = new Download(server);
-		downloadHandler.handleDownload(handle, path, true);
-		if (!handle.hasBeenUsed()) {
-			String message = String.format("Call to %s.handleDownload for path '%s' sent neither data nor an error message",
-					downloadHandler.getClass().getCanonicalName(), path);
-			throw new IOException(message);
+		try {
+			downloadHandler.handleDownload(handle, path, true);
+			if (!handle.hasBeenUsed()) {
+				String message = String.format("Call to %s.handleDownload for path '%s' sent neither data nor an error message",
+						downloadHandler.getClass().getCanonicalName(), path);
+				throw new IOException(message);
+			}
+		} finally {
+			handle.close();
 		}
-		handle.close();
 		return handle.getError();
 	}