Skip to content

Commit

Permalink
fix: Fixes issue pgjdbc#1592 where one thread is reading the copy and…
Browse files Browse the repository at this point in the history
… another thread closes the connection
  • Loading branch information
davecramer committed Oct 29, 2019
1 parent 003ea83 commit 8ac14c5
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 @@ -592,4 +592,8 @@ public void setNetworkTimeout(int milliseconds) throws IOException {
public int getNetworkTimeout() throws IOException {
return connection.getSoTimeout();
}

public boolean isClosed() {
return connection.isClosed();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,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 8ac14c5

Please sign in to comment.