Skip to content
Permalink
Browse files
fix: Fixes issue #1592 where one thread is reading the copy and anoth…
…er thread closes the connection (#1594)

* fix: Fixes issue #1592 where one thread is reading the copy and another thread closes the connection
  • Loading branch information
davecramer committed Jan 30, 2020
1 parent a7480d2 commit 1191076c8141ce796d4bae9bb7e8bc955aae528a
Showing with 11 additions and 0 deletions.
  1. +4 −0 pgjdbc/src/main/java/org/postgresql/core/PGStream.java
  2. +7 −0 pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java
@@ -668,4 +668,8 @@ private void increaseByteCounter(long value) throws SQLException {
}
}
}

public boolean isClosed() {
return connection.isClosed();
}
}
@@ -1091,6 +1091,13 @@ synchronized void readFromCopy(CopyOperationImpl op, boolean block) throws SQLEx
CopyOperationImpl processCopyResults(CopyOperationImpl op, boolean block)
throws SQLException, IOException {

/*
* fixes issue #1592 where one thread closes the stream and another is reading it
*/
if (pgStream.isClosed()) {
throw new PSQLException(GT.tr("PGStream is closed",
op.getClass().getName()), PSQLState.CONNECTION_DOES_NOT_EXIST);
}
/*
* This is a hack as we should not end up here, but sometimes do with large copy operations.
*/

0 comments on commit 1191076

Please sign in to comment.