From 976da4aa6126aefd775b7c223c71e29d1207bf10 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 11 Dec 2013 17:17:53 +0000
Subject: [PATCH] Fix OPENDJ-1247: Client side timeouts do not cancel bind or startTLS requests properly
---
opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPFutureResultImpl.java | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPFutureResultImpl.java b/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPFutureResultImpl.java
index 0558a48..a7b896c 100644
--- a/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPFutureResultImpl.java
+++ b/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/AbstractLDAPFutureResultImpl.java
@@ -94,11 +94,34 @@
*/
@Override
protected final ErrorResultException handleCancelRequest(final boolean mayInterruptIfRunning) {
+ /*
+ * This will abandon the request, but will also recursively cancel this
+ * future. There is no risk of an infinite loop because the state of
+ * this future has already been changed.
+ */
connection.abandonAsync(Requests.newAbandonRequest(requestID));
return null;
}
@Override
+ protected final boolean isCancelable() {
+ /*
+ * No other operations can be performed while a bind or startTLS
+ * operations is active. Therefore it is not possible to cancel bind or
+ * startTLS requests, since doing so will leave the connection in a
+ * state which prevents other operations from being performed.
+ */
+ return !isBindOrStartTLS();
+ }
+
+ /**
+ * Returns {@code false} by default.
+ */
+ boolean isBindOrStartTLS() {
+ return false;
+ }
+
+ @Override
protected void toString(final StringBuilder sb) {
sb.append(" requestID = ");
sb.append(requestID);
--
Gitblit v1.10.0