[libpostgresql-jdbc-java] 03/05: fix: abort connection on I/O error instead of closing
Emmanuel Bourg
ebourg-guest at moszumanska.debian.org
Mon Jan 9 21:17:42 UTC 2017
This is an automated email from the git hooks/post-receive script.
ebourg-guest pushed a commit to tag REL9_3_1104
in repository libpostgresql-jdbc-java.
commit 23e22cbb3288960736032c3297e5dd2aa5cb4a67
Author: Dave Cramer <davecramer at gmail.com>
Date: Thu Oct 8 10:54:10 2015 -0400
fix: abort connection on I/O error instead of closing
---
org/postgresql/core/ProtocolConnection.java | 7 +++++++
org/postgresql/core/v2/ProtocolConnectionImpl.java | 17 +++++++++++++++++
org/postgresql/core/v2/QueryExecutorImpl.java | 2 +-
org/postgresql/core/v3/ProtocolConnectionImpl.java | 17 +++++++++++++++++
org/postgresql/core/v3/QueryExecutorImpl.java | 8 ++++----
5 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/org/postgresql/core/ProtocolConnection.java b/org/postgresql/core/ProtocolConnection.java
index cfd7bce..61513c6 100644
--- a/org/postgresql/core/ProtocolConnection.java
+++ b/org/postgresql/core/ProtocolConnection.java
@@ -148,4 +148,11 @@ public interface ProtocolConnection {
* Return the process ID (PID) of the backend server process handling this connection.
*/
public int getBackendPID();
+
+ /**
+ * Do not attempt to send anything to the backend, just close the underlying connection
+ * and mark the protocol closed
+ *
+ */
+ public void abort();
}
diff --git a/org/postgresql/core/v2/ProtocolConnectionImpl.java b/org/postgresql/core/v2/ProtocolConnectionImpl.java
index 677c48a..89af146 100644
--- a/org/postgresql/core/v2/ProtocolConnectionImpl.java
+++ b/org/postgresql/core/v2/ProtocolConnectionImpl.java
@@ -143,6 +143,23 @@ class ProtocolConnectionImpl implements ProtocolConnection {
closed = true;
}
+ /*
+ * (non-Javadoc)
+ * @see org.postgresql.core.ProtocolConnection#abort()
+ */
+ public void abort()
+ {
+ try
+ {
+ pgStream.getSocket().close();
+ }
+ catch (IOException e)
+ {
+ // ignore
+ }
+ closed = true;
+ }
+
public Encoding getEncoding() {
return pgStream.getEncoding();
}
diff --git a/org/postgresql/core/v2/QueryExecutorImpl.java b/org/postgresql/core/v2/QueryExecutorImpl.java
index 738d765..f4ecd0a 100644
--- a/org/postgresql/core/v2/QueryExecutorImpl.java
+++ b/org/postgresql/core/v2/QueryExecutorImpl.java
@@ -365,7 +365,7 @@ public class QueryExecutorImpl implements QueryExecutor {
}
catch (IOException e)
{
- protoConnection.close();
+ protoConnection.abort();
handler.handleError(new PSQLException(GT.tr("An I/O error occurred while sending to the backend."), PSQLState.CONNECTION_FAILURE, e));
}
diff --git a/org/postgresql/core/v3/ProtocolConnectionImpl.java b/org/postgresql/core/v3/ProtocolConnectionImpl.java
index 75e911e..c674065 100644
--- a/org/postgresql/core/v3/ProtocolConnectionImpl.java
+++ b/org/postgresql/core/v3/ProtocolConnectionImpl.java
@@ -147,6 +147,23 @@ class ProtocolConnectionImpl implements ProtocolConnection {
closed = true;
}
+ /*
+ * (non-Javadoc)
+ * @see org.postgresql.core.ProtocolConnection#abort()
+ */
+ public void abort()
+ {
+ try
+ {
+ pgStream.getSocket().close();
+ }
+ catch (IOException e)
+ {
+ // ignore
+ }
+ closed = true;
+ }
+
public Encoding getEncoding() {
return pgStream.getEncoding();
}
diff --git a/org/postgresql/core/v3/QueryExecutorImpl.java b/org/postgresql/core/v3/QueryExecutorImpl.java
index 34f2e65..6a67681 100644
--- a/org/postgresql/core/v3/QueryExecutorImpl.java
+++ b/org/postgresql/core/v3/QueryExecutorImpl.java
@@ -277,7 +277,7 @@ public class QueryExecutorImpl implements QueryExecutor {
}
catch (IOException e)
{
- protoConnection.close();
+ protoConnection.abort();
handler.handleError(new PSQLException(GT.tr("An I/O error occurred while sending to the backend."), PSQLState.CONNECTION_FAILURE, e));
}
@@ -407,7 +407,7 @@ public class QueryExecutorImpl implements QueryExecutor {
}
catch (IOException e)
{
- protoConnection.close();
+ protoConnection.abort();
handler.handleError(new PSQLException(GT.tr("An I/O error occurred while sending to the backend."), PSQLState.CONNECTION_FAILURE, e));
}
@@ -485,7 +485,7 @@ public class QueryExecutorImpl implements QueryExecutor {
}
catch (IOException ioe)
{
- protoConnection.close();
+ protoConnection.abort();
throw new PSQLException(GT.tr("An I/O error occurred while sending to the backend."), PSQLState.CONNECTION_FAILURE, ioe);
}
}
@@ -2131,7 +2131,7 @@ public class QueryExecutorImpl implements QueryExecutor {
}
catch (IOException e)
{
- protoConnection.close();
+ protoConnection.abort();
handler.handleError(new PSQLException(GT.tr("An I/O error occurred while sending to the backend."), PSQLState.CONNECTION_FAILURE, e));
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git
More information about the pkg-java-commits
mailing list