pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: sehrope (@sehrope) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] PR #4190: Fix deleting temp file when spooling large stream to disk in StreamWrapper
Date: Mon, 15 Jun 2026 20:33:11 +0000
Message-ID: <[email protected]> (raw)

The cleanup block catches the rest of exception types but is noticeably missing handling for `IOException`. So if there's an error writing to the file, the temp file will stay on disk. Even though it's a checked exception, this wasn't noticed because the outer try-catch handling `IOException`.

Fix is to just add that additional exception type in the catch. It'll get rethrown immediately after attempting to remove the temp file so there's no change in error handling behavior either.

diff --git a/pgjdbc/src/main/java/org/postgresql/util/StreamWrapper.java b/pgjdbc/src/main/java/org/postgresql/util/StreamWrapper.java
index 8c1190d192..c10f9efd83 100644
--- a/pgjdbc/src/main/java/org/postgresql/util/StreamWrapper.java
+++ b/pgjdbc/src/main/java/org/postgresql/util/StreamWrapper.java
@@ -60,7 +60,7 @@ public StreamWrapper(InputStream stream) throws PSQLException {
             throw new PSQLException(GT.tr("Object is too large to send over the protocol."),
                 PSQLState.NUMERIC_CONSTANT_OUT_OF_RANGE);
           }
-        } catch (RuntimeException | Error | PSQLException e) {
+        } catch (RuntimeException | Error | PSQLException | IOException e) {
           try {
             tempFile.toFile().delete();
           } catch (Throwable ignore) {


reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] PR #4190: Fix deleting temp file when spooling large stream to disk in StreamWrapper
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox