diff --git a/driver/src/main/java/com/impossibl/postgres/jdbc/CancelRequestTask.java b/driver/src/main/java/com/impossibl/postgres/jdbc/CancelRequestTask.java index a4b655ed3..afbbbcc59 100644 --- a/driver/src/main/java/com/impossibl/postgres/jdbc/CancelRequestTask.java +++ b/driver/src/main/java/com/impossibl/postgres/jdbc/CancelRequestTask.java @@ -44,11 +44,14 @@ import java.net.Socket; import java.net.SocketAddress; import java.nio.ByteBuffer; +import java.util.logging.Logger; import io.netty.channel.unix.DomainSocketAddress; public class CancelRequestTask extends ExecutionTimerTask { + private static final Logger logger = Logger.getLogger(CancelRequestTask.class.getName()); + private SocketAddress serverAddress; private ServerConnection.KeyData keyData; @@ -64,6 +67,11 @@ public void go() { private void sendCancelRequest() { + if (keyData.getProcessId() == 0 && keyData.getSecretKey() == 0) { + logger.warning("Cannot send CancelRequest because of missing BackendKeyData."); + return; + } + try { if (serverAddress instanceof InetSocketAddress) { diff --git a/driver/src/main/java/com/impossibl/postgres/protocol/v30/ServerConnectionFactory.java b/driver/src/main/java/com/impossibl/postgres/protocol/v30/ServerConnectionFactory.java index 79517b1cf..311109824 100644 --- a/driver/src/main/java/com/impossibl/postgres/protocol/v30/ServerConnectionFactory.java +++ b/driver/src/main/java/com/impossibl/postgres/protocol/v30/ServerConnectionFactory.java @@ -495,7 +495,7 @@ public void handleNegotiate(Version maxProtocolVersion, List unrecognize } @Override - public void handleComplete(Integer processId, Integer secretKey, Map parameterStatuses, List notices) { + public void handleComplete(int processId, int secretKey, Map parameterStatuses, List notices) { startupParameterStatuses.putAll(parameterStatuses); startupKeyData.set(new KeyData(processId, secretKey)); diff --git a/driver/src/main/java/com/impossibl/postgres/protocol/v30/StartupRequest.java b/driver/src/main/java/com/impossibl/postgres/protocol/v30/StartupRequest.java index 1187f8e00..110367995 100644 --- a/driver/src/main/java/com/impossibl/postgres/protocol/v30/StartupRequest.java +++ b/driver/src/main/java/com/impossibl/postgres/protocol/v30/StartupRequest.java @@ -63,7 +63,7 @@ interface CompletionHandler { void handleNegotiate(Version maxProtocolVersion, List unrecognizedParameters) throws IOException; - void handleComplete(Integer processId, Integer secretKey, Map parameterStatuses, List notices) throws IOException; + void handleComplete(int processId, int secretKey, Map parameterStatuses, List notices) throws IOException; void handleError(Throwable cause, List notices) throws IOException; } @@ -71,8 +71,8 @@ interface CompletionHandler { private Version protocolVersion; private Map startupParameters; private CompletionHandler handler; - private Integer backendProcessId; - private Integer backendSecretKey; + private int backendProcessId; + private int backendSecretKey; private Map parameterStatuses; private List notices;