Skip to content

Commit

Permalink
fix: Fixes issue #1592 where one thread is reading the copy and anoth…
Browse files Browse the repository at this point in the history
…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 1191076
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pgjdbc/src/main/java/org/postgresql/core/PGStream.java
Original file line number Diff line number Diff line change
Expand Up @@ -668,4 +668,8 @@ private void increaseByteCounter(long value) throws SQLException {
}
}
}

public boolean isClosed() {
return connection.isClosed();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down

0 comments on commit 1191076

Please sign in to comment.