From f134ef63e016bf13b70bef1ec277603b8a9a6f21 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 25 Apr 2012 11:06:50 +0000
Subject: [PATCH] Fix OPENDJ-474: Remove requirement for clients to deal with InterruptedExceptions in synchronous APIs
---
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java | 8
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ErrorResultException.java | 2
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java | 5
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java | 32 --
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connection.java | 98 ++------
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionPool.java | 6
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java | 10
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java | 20 -
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnectionFactoryImpl.java | 8
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java | 6
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LoadBalancer.java | 4
opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java | 58 ++---
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RootDSE.java | 5
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java | 4
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java | 8
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java | 11
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Modify.java | 6
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/InternalConnectionFactory.java | 4
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java | 11
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java | 52 ----
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java | 6
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthenticatedConnectionFactory.java | 11
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FixedConnectionPool.java | 82 +++----
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java | 17 -
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnection.java | 44 ++-
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/HeartBeatConnectionFactory.java | 4
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractLoadBalancingAlgorithm.java | 4
opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java | 20 -
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBind.java | 5
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryWriter.java | 9
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionChangeRecordWriter.java | 31 --
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connections.java | 2
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPListenerTestCase.java | 14
opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ReadSchema.java | 7
opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java | 37 +--
35 files changed, 205 insertions(+), 446 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
index 5b668bb..788943a 100644
--- a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
+++ b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/GetInfo.java
@@ -97,10 +97,6 @@
System.err.println(e.getMessage());
System.exit(e.getResult().getResultCode().intValue());
return;
- } catch (final InterruptedException e) {
- System.err.println(e.getMessage());
- System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
- return;
} catch (final IOException e) {
System.err.println(e.getMessage());
System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
diff --git a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Modify.java b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Modify.java
index 8d77837..02aeb4d 100644
--- a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Modify.java
+++ b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Modify.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2012 ForgeRock AS
*/
package org.forgerock.opendj.examples;
@@ -108,10 +108,6 @@
System.err.println(e.getMessage());
System.exit(e.getResult().getResultCode().intValue());
return;
- } catch (final InterruptedException e) {
- System.err.println(e.getMessage());
- System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
- return;
} catch (final IOException e) {
System.err.println(e.getMessage());
System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
diff --git a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ReadSchema.java b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ReadSchema.java
index 2e47427..a14c72b 100644
--- a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ReadSchema.java
+++ b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/ReadSchema.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2012 ForgeRock AS
*/
package org.forgerock.opendj.examples;
@@ -32,7 +32,6 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
-import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.schema.AttributeType;
import org.forgerock.opendj.ldap.schema.MatchingRule;
import org.forgerock.opendj.ldap.schema.ObjectClass;
@@ -113,10 +112,6 @@
System.err.println(e.getMessage());
System.exit(e.getResult().getResultCode().intValue());
return;
- } catch (final InterruptedException e) {
- System.err.println(e.getMessage());
- System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
- return;
} finally {
if (connection != null) {
connection.close();
diff --git a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java
index e664b9d..110174e 100644
--- a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java
+++ b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SASLAuth.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Copyright 2011 ForgeRock AS
+ * Copyright 2011-2012 ForgeRock AS
*/
/**
@@ -100,10 +100,6 @@
System.err.println(e.getMessage());
System.exit(e.getResult().getResultCode().intValue());
return;
- } catch (final InterruptedException e) {
- System.err.println(e.getMessage());
- System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
- return;
} catch (final GeneralSecurityException e) {
System.err.println(e.getMessage());
System.exit(ResultCode.CLIENT_SIDE_CONNECT_ERROR.intValue());
diff --git a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java
index 0bbe01d..17bfbc8 100644
--- a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java
+++ b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Search.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2012 ForgeRock AS
*/
package org.forgerock.opendj.examples;
@@ -131,10 +131,6 @@
System.err.println(e.getMessage());
System.exit(e.getCause().getResult().getResultCode().intValue());
return;
- } catch (final InterruptedException e) {
- System.err.println(e.getMessage());
- System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
- return;
} catch (final IOException e) {
System.err.println(e.getMessage());
System.exit(ResultCode.CLIENT_SIDE_LOCAL_ERROR.intValue());
diff --git a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBind.java b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBind.java
index 3527910..657738d 100644
--- a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBind.java
+++ b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SearchBind.java
@@ -32,7 +32,6 @@
import org.forgerock.opendj.ldap.DN;
import org.forgerock.opendj.ldap.ErrorResultException;
import org.forgerock.opendj.ldap.LDAPConnectionFactory;
-import org.forgerock.opendj.ldap.ResultCode;
import org.forgerock.opendj.ldap.SearchScope;
import org.forgerock.opendj.ldap.responses.BindResult;
import org.forgerock.opendj.ldap.responses.SearchResultEntry;
@@ -98,10 +97,6 @@
System.err.println("Failed to bind.");
System.exit(e.getResult().getResultCode().intValue());
return;
- } catch (final InterruptedException e) {
- System.err.println(e.getMessage());
- System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
- return;
} finally {
if (connection != null) {
connection.close();
diff --git a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
index 39c77d3..37c5ca0 100644
--- a/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
+++ b/opendj3/opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/SimpleAuth.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Copyright 2011 ForgeRock AS
+ * Copyright 2011-2012 ForgeRock AS
*/
package org.forgerock.opendj.examples;
@@ -88,10 +88,6 @@
System.err.println(e.getMessage());
System.exit(e.getResult().getResultCode().intValue());
return;
- } catch (final InterruptedException e) {
- System.err.println(e.getMessage());
- System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
- return;
} finally {
if (connection != null) {
connection.close();
@@ -135,10 +131,6 @@
System.err.println(e.getMessage());
System.exit(e.getResult().getResultCode().intValue());
return;
- } catch (final InterruptedException e) {
- System.err.println(e.getMessage());
- System.exit(ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue());
- return;
} catch (final GeneralSecurityException e) {
System.err.println(e.getMessage());
System.exit(ResultCode.CLIENT_SIDE_CONNECT_ERROR.intValue());
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnectionFactoryImpl.java b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnectionFactoryImpl.java
index f321050..3563302 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnectionFactoryImpl.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/ldap/LDAPConnectionFactoryImpl.java
@@ -220,8 +220,12 @@
* {@inheritDoc}
*/
@Override
- public Connection getConnection() throws ErrorResultException, InterruptedException {
- return getConnectionAsync(null).get();
+ public Connection getConnection() throws ErrorResultException {
+ try {
+ return getConnectionAsync(null).get();
+ } catch (InterruptedException e) {
+ throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e);
+ }
}
/**
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java
index ed16252..28bfeed 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/com/forgerock/opendj/util/ConnectionDecorator.java
@@ -97,7 +97,7 @@
* The default implementation is to delegate.
*/
@Override
- public Result add(final AddRequest request) throws ErrorResultException, InterruptedException {
+ public Result add(final AddRequest request) throws ErrorResultException {
return connection.add(request);
}
@@ -107,7 +107,7 @@
* The default implementation is to delegate.
*/
@Override
- public Result add(final Entry entry) throws ErrorResultException, InterruptedException {
+ public Result add(final Entry entry) throws ErrorResultException {
return connection.add(entry);
}
@@ -117,7 +117,7 @@
* The default implementation is to delegate.
*/
@Override
- public Result add(final String... ldifLines) throws ErrorResultException, InterruptedException {
+ public Result add(final String... ldifLines) throws ErrorResultException {
return connection.add(ldifLines);
}
@@ -149,8 +149,7 @@
* The default implementation is to delegate.
*/
@Override
- public BindResult bind(final BindRequest request) throws ErrorResultException,
- InterruptedException {
+ public BindResult bind(final BindRequest request) throws ErrorResultException {
return connection.bind(request);
}
@@ -160,8 +159,7 @@
* The default implementation is to delegate.
*/
@Override
- public BindResult bind(final String name, final char[] password) throws ErrorResultException,
- InterruptedException {
+ public BindResult bind(final String name, final char[] password) throws ErrorResultException {
return connection.bind(name, password);
}
@@ -203,8 +201,7 @@
* The default implementation is to delegate.
*/
@Override
- public CompareResult compare(final CompareRequest request) throws ErrorResultException,
- InterruptedException {
+ public CompareResult compare(final CompareRequest request) throws ErrorResultException {
return connection.compare(request);
}
@@ -215,7 +212,7 @@
*/
@Override
public CompareResult compare(final String name, final String attributeDescription,
- final String assertionValue) throws ErrorResultException, InterruptedException {
+ final String assertionValue) throws ErrorResultException {
return connection.compare(name, attributeDescription, assertionValue);
}
@@ -237,8 +234,7 @@
* The default implementation is to delegate.
*/
@Override
- public Result delete(final DeleteRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result delete(final DeleteRequest request) throws ErrorResultException {
return connection.delete(request);
}
@@ -248,7 +244,7 @@
* The default implementation is to delegate.
*/
@Override
- public Result delete(final String name) throws ErrorResultException, InterruptedException {
+ public Result delete(final String name) throws ErrorResultException {
return connection.delete(name);
}
@@ -271,7 +267,7 @@
*/
@Override
public <R extends ExtendedResult> R extendedRequest(final ExtendedRequest<R> request)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return connection.extendedRequest(request);
}
@@ -282,8 +278,7 @@
*/
@Override
public <R extends ExtendedResult> R extendedRequest(final ExtendedRequest<R> request,
- final IntermediateResponseHandler handler) throws ErrorResultException,
- InterruptedException {
+ final IntermediateResponseHandler handler) throws ErrorResultException {
return connection.extendedRequest(request, handler);
}
@@ -294,7 +289,7 @@
*/
@Override
public GenericExtendedResult extendedRequest(final String requestName,
- final ByteString requestValue) throws ErrorResultException, InterruptedException {
+ final ByteString requestValue) throws ErrorResultException {
return connection.extendedRequest(requestName, requestValue);
}
@@ -337,8 +332,7 @@
* The default implementation is to delegate.
*/
@Override
- public Result modify(final ModifyRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result modify(final ModifyRequest request) throws ErrorResultException {
return connection.modify(request);
}
@@ -348,8 +342,7 @@
* The default implementation is to delegate.
*/
@Override
- public Result modify(final String... ldifLines) throws ErrorResultException,
- InterruptedException {
+ public Result modify(final String... ldifLines) throws ErrorResultException {
return connection.modify(ldifLines);
}
@@ -371,8 +364,7 @@
* The default implementation is to delegate.
*/
@Override
- public Result modifyDN(final ModifyDNRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result modifyDN(final ModifyDNRequest request) throws ErrorResultException {
return connection.modifyDN(request);
}
@@ -382,8 +374,7 @@
* The default implementation is to delegate.
*/
@Override
- public Result modifyDN(final String name, final String newRDN) throws ErrorResultException,
- InterruptedException {
+ public Result modifyDN(final String name, final String newRDN) throws ErrorResultException {
return connection.modifyDN(name, newRDN);
}
@@ -406,7 +397,7 @@
*/
@Override
public SearchResultEntry readEntry(final DN name, final String... attributeDescriptions)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return connection.readEntry(name, attributeDescriptions);
}
@@ -417,7 +408,7 @@
*/
@Override
public SearchResultEntry readEntry(final String name, final String... attributeDescriptions)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return connection.readEntry(name, attributeDescriptions);
}
@@ -460,8 +451,7 @@
*/
@Override
public Result search(final SearchRequest request,
- final Collection<? super SearchResultEntry> entries) throws ErrorResultException,
- InterruptedException {
+ final Collection<? super SearchResultEntry> entries) throws ErrorResultException {
return connection.search(request, entries);
}
@@ -473,8 +463,7 @@
@Override
public Result search(final SearchRequest request,
final Collection<? super SearchResultEntry> entries,
- final Collection<? super SearchResultReference> references)
- throws ErrorResultException, InterruptedException {
+ final Collection<? super SearchResultReference> references) throws ErrorResultException {
return connection.search(request, entries, references);
}
@@ -485,7 +474,7 @@
*/
@Override
public Result search(final SearchRequest request, final SearchResultHandler handler)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return connection.search(request, handler);
}
@@ -519,7 +508,7 @@
*/
@Override
public SearchResultEntry searchSingleEntry(final SearchRequest request)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return connection.searchSingleEntry(request);
}
@@ -530,8 +519,7 @@
*/
@Override
public SearchResultEntry searchSingleEntry(final String baseObject, final SearchScope scope,
- final String filter, final String... attributeDescriptions)
- throws ErrorResultException, InterruptedException {
+ final String filter, final String... attributeDescriptions) throws ErrorResultException {
return connection.searchSingleEntry(baseObject, scope, filter, attributeDescriptions);
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnection.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnection.java
index c9827a2..235e173 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnection.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractAsynchronousConnection.java
@@ -27,6 +27,8 @@
package org.forgerock.opendj.ldap;
+import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
+
import org.forgerock.opendj.ldap.requests.AddRequest;
import org.forgerock.opendj.ldap.requests.BindRequest;
import org.forgerock.opendj.ldap.requests.CompareRequest;
@@ -57,10 +59,12 @@
* {@inheritDoc}
*/
@Override
- public Result add(final AddRequest request) throws ErrorResultException, InterruptedException {
+ public Result add(final AddRequest request) throws ErrorResultException {
final FutureResult<Result> future = addAsync(request, null, null);
try {
return future.get();
+ } catch (InterruptedException e) {
+ throw interrupted(e);
} finally {
// Cancel the request if it hasn't completed.
future.cancel(false);
@@ -71,11 +75,12 @@
* {@inheritDoc}
*/
@Override
- public BindResult bind(final BindRequest request) throws ErrorResultException,
- InterruptedException {
+ public BindResult bind(final BindRequest request) throws ErrorResultException {
final FutureResult<BindResult> future = bindAsync(request, null, null);
try {
return future.get();
+ } catch (InterruptedException e) {
+ throw interrupted(e);
} finally {
// Cancel the request if it hasn't completed.
future.cancel(false);
@@ -86,11 +91,12 @@
* {@inheritDoc}
*/
@Override
- public CompareResult compare(final CompareRequest request) throws ErrorResultException,
- InterruptedException {
+ public CompareResult compare(final CompareRequest request) throws ErrorResultException {
final FutureResult<CompareResult> future = compareAsync(request, null, null);
try {
return future.get();
+ } catch (InterruptedException e) {
+ throw interrupted(e);
} finally {
// Cancel the request if it hasn't completed.
future.cancel(false);
@@ -101,11 +107,12 @@
* {@inheritDoc}
*/
@Override
- public Result delete(final DeleteRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result delete(final DeleteRequest request) throws ErrorResultException {
final FutureResult<Result> future = deleteAsync(request, null, null);
try {
return future.get();
+ } catch (InterruptedException e) {
+ throw interrupted(e);
} finally {
// Cancel the request if it hasn't completed.
future.cancel(false);
@@ -117,11 +124,12 @@
*/
@Override
public <R extends ExtendedResult> R extendedRequest(final ExtendedRequest<R> request,
- final IntermediateResponseHandler handler) throws ErrorResultException,
- InterruptedException {
+ final IntermediateResponseHandler handler) throws ErrorResultException {
final FutureResult<R> future = extendedRequestAsync(request, handler, null);
try {
return future.get();
+ } catch (InterruptedException e) {
+ throw interrupted(e);
} finally {
// Cancel the request if it hasn't completed.
future.cancel(false);
@@ -132,11 +140,12 @@
* {@inheritDoc}
*/
@Override
- public Result modify(final ModifyRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result modify(final ModifyRequest request) throws ErrorResultException {
final FutureResult<Result> future = modifyAsync(request, null, null);
try {
return future.get();
+ } catch (InterruptedException e) {
+ throw interrupted(e);
} finally {
// Cancel the request if it hasn't completed.
future.cancel(false);
@@ -147,11 +156,12 @@
* {@inheritDoc}
*/
@Override
- public Result modifyDN(final ModifyDNRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result modifyDN(final ModifyDNRequest request) throws ErrorResultException {
final FutureResult<Result> future = modifyDNAsync(request, null, null);
try {
return future.get();
+ } catch (InterruptedException e) {
+ throw interrupted(e);
} finally {
// Cancel the request if it hasn't completed.
future.cancel(false);
@@ -163,14 +173,20 @@
*/
@Override
public Result search(final SearchRequest request, final SearchResultHandler handler)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
final FutureResult<Result> future = searchAsync(request, null, handler);
try {
return future.get();
+ } catch (InterruptedException e) {
+ throw interrupted(e);
} finally {
// Cancel the request if it hasn't completed.
future.cancel(false);
}
}
+ // Handle thread interruption.
+ private ErrorResultException interrupted(InterruptedException e) {
+ return newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e);
+ }
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java
index 00a384c..fa14670 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractConnection.java
@@ -217,7 +217,7 @@
* {@inheritDoc}
*/
@Override
- public Result add(final Entry entry) throws ErrorResultException, InterruptedException {
+ public Result add(final Entry entry) throws ErrorResultException {
return add(Requests.newAddRequest(entry));
}
@@ -225,7 +225,7 @@
* {@inheritDoc}
*/
@Override
- public Result add(final String... ldifLines) throws ErrorResultException, InterruptedException {
+ public Result add(final String... ldifLines) throws ErrorResultException {
return add(Requests.newAddRequest(ldifLines));
}
@@ -233,8 +233,7 @@
* {@inheritDoc}
*/
@Override
- public BindResult bind(final String name, final char[] password) throws ErrorResultException,
- InterruptedException {
+ public BindResult bind(final String name, final char[] password) throws ErrorResultException {
return bind(Requests.newSimpleBindRequest(name, password));
}
@@ -251,7 +250,7 @@
*/
@Override
public CompareResult compare(final String name, final String attributeDescription,
- final String assertionValue) throws ErrorResultException, InterruptedException {
+ final String assertionValue) throws ErrorResultException {
return compare(Requests.newCompareRequest(name, attributeDescription, assertionValue));
}
@@ -259,7 +258,7 @@
* {@inheritDoc}
*/
@Override
- public Result delete(final String name) throws ErrorResultException, InterruptedException {
+ public Result delete(final String name) throws ErrorResultException {
return delete(Requests.newDeleteRequest(name));
}
@@ -268,7 +267,7 @@
*/
@Override
public <R extends ExtendedResult> R extendedRequest(final ExtendedRequest<R> request)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return extendedRequest(request, null);
}
@@ -277,7 +276,7 @@
*/
@Override
public GenericExtendedResult extendedRequest(final String requestName,
- final ByteString requestValue) throws ErrorResultException, InterruptedException {
+ final ByteString requestValue) throws ErrorResultException {
return extendedRequest(Requests.newGenericExtendedRequest(requestName, requestValue));
}
@@ -285,8 +284,7 @@
* {@inheritDoc}
*/
@Override
- public Result modify(final String... ldifLines) throws ErrorResultException,
- InterruptedException {
+ public Result modify(final String... ldifLines) throws ErrorResultException {
return modify(Requests.newModifyRequest(ldifLines));
}
@@ -294,8 +292,7 @@
* {@inheritDoc}
*/
@Override
- public Result modifyDN(final String name, final String newRDN) throws ErrorResultException,
- InterruptedException {
+ public Result modifyDN(final String name, final String newRDN) throws ErrorResultException {
return modifyDN(Requests.newModifyDNRequest(name, newRDN));
}
@@ -304,7 +301,7 @@
*/
@Override
public SearchResultEntry readEntry(final DN baseObject, final String... attributeDescriptions)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
final SearchRequest request =
Requests.newSearchRequest(baseObject, SearchScope.BASE_OBJECT, Filter
.getObjectClassPresentFilter(), attributeDescriptions);
@@ -316,8 +313,7 @@
*/
@Override
public SearchResultEntry readEntry(final String baseObject,
- final String... attributeDescriptions) throws ErrorResultException,
- InterruptedException {
+ final String... attributeDescriptions) throws ErrorResultException {
return readEntry(DN.valueOf(baseObject));
}
@@ -350,8 +346,7 @@
*/
@Override
public Result search(final SearchRequest request,
- final Collection<? super SearchResultEntry> entries) throws ErrorResultException,
- InterruptedException {
+ final Collection<? super SearchResultEntry> entries) throws ErrorResultException {
return search(request, entries, null);
}
@@ -361,8 +356,7 @@
@Override
public Result search(final SearchRequest request,
final Collection<? super SearchResultEntry> entries,
- final Collection<? super SearchResultReference> references)
- throws ErrorResultException, InterruptedException {
+ final Collection<? super SearchResultReference> references) throws ErrorResultException {
Validator.ensureNotNull(request, entries);
// FIXME: does this need to be thread safe?
@@ -418,7 +412,7 @@
*/
@Override
public SearchResultEntry searchSingleEntry(final SearchRequest request)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
final SingleEntryHandler handler = new SingleEntryHandler();
search(request, handler);
@@ -445,8 +439,7 @@
*/
@Override
public SearchResultEntry searchSingleEntry(final String baseObject, final SearchScope scope,
- final String filter, final String... attributeDescriptions)
- throws ErrorResultException, InterruptedException {
+ final String filter, final String... attributeDescriptions) throws ErrorResultException {
final SearchRequest request =
Requests.newSearchRequest(baseObject, scope, filter, attributeDescriptions);
return searchSingleEntry(request);
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractLoadBalancingAlgorithm.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractLoadBalancingAlgorithm.java
index 06b5348..3951e19 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractLoadBalancingAlgorithm.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AbstractLoadBalancingAlgorithm.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS.
+ * Portions copyright 2011-2012 ForgeRock AS.
*/
package org.forgerock.opendj.ldap;
@@ -70,7 +70,7 @@
/**
* {@inheritDoc}
*/
- public Connection getConnection() throws ErrorResultException, InterruptedException {
+ public Connection getConnection() throws ErrorResultException {
final Connection connection;
try {
connection = factory.getConnection();
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthenticatedConnectionFactory.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthenticatedConnectionFactory.java
index 93cdff3..eef6cd0 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthenticatedConnectionFactory.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/AuthenticatedConnectionFactory.java
@@ -75,16 +75,14 @@
/**
* {@inheritDoc}
*/
- public BindResult bind(BindRequest request) throws ErrorResultException,
- InterruptedException {
+ public BindResult bind(BindRequest request) throws ErrorResultException {
throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*/
- public BindResult bind(String name, char[] password) throws ErrorResultException,
- InterruptedException {
+ public BindResult bind(String name, char[] password) throws ErrorResultException {
throw new UnsupportedOperationException();
}
@@ -175,7 +173,7 @@
/**
* {@inheritDoc}
*/
- public Connection getConnection() throws ErrorResultException, InterruptedException {
+ public Connection getConnection() throws ErrorResultException {
final Connection connection = parentFactory.getConnection();
boolean bindSucceeded = false;
try {
@@ -187,8 +185,7 @@
}
}
// If the bind didn't succeed then an exception will have been thrown
- // and
- // this line will not be reached.
+ // and this line will not be reached.
return new AuthenticatedConnection(connection);
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connection.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connection.java
index ba49493..6a727a2 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connection.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connection.java
@@ -70,7 +70,8 @@
* <p>
* Since synchronous operations block the calling thread, the only way to
* abandon a long running operation is to interrupt the calling thread from
- * another thread. This will cause the calling thread unblock and throw an
+ * another thread. This will cause the calling thread unblock and throw a
+ * {@link CancelledResultException} whose cause is the underlying
* {@link InterruptedException}.
* <p>
* <h4>Performing operations asynchronously</h4>
@@ -184,8 +185,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support add operations.
* @throws IllegalStateException
@@ -194,7 +193,7 @@
* @throws NullPointerException
* If {@code request} was {@code null}.
*/
- Result add(AddRequest request) throws ErrorResultException, InterruptedException;
+ Result add(AddRequest request) throws ErrorResultException;
/**
* Adds the provided entry to the Directory Server.
@@ -212,8 +211,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support add operations.
* @throws IllegalStateException
@@ -222,7 +219,7 @@
* @throws NullPointerException
* If {@code entry} was {@code null} .
*/
- Result add(Entry entry) throws ErrorResultException, InterruptedException;
+ Result add(Entry entry) throws ErrorResultException;
/**
* Adds an entry to the Directory Server using the provided lines of LDIF.
@@ -241,8 +238,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support add operations.
* @throws LocalizedIllegalArgumentException
@@ -254,7 +249,7 @@
* @throws NullPointerException
* If {@code ldifLines} was {@code null} .
*/
- Result add(String... ldifLines) throws ErrorResultException, InterruptedException;
+ Result add(String... ldifLines) throws ErrorResultException;
/**
* Asynchronously adds an entry to the Directory Server using the provided
@@ -307,8 +302,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support bind operations.
* @throws IllegalStateException
@@ -317,7 +310,7 @@
* @throws NullPointerException
* If {@code request} was {@code null}.
*/
- BindResult bind(BindRequest request) throws ErrorResultException, InterruptedException;
+ BindResult bind(BindRequest request) throws ErrorResultException;
/**
* Authenticates to the Directory Server using simple authentication and the
@@ -340,8 +333,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws LocalizedIllegalArgumentException
* If {@code name} could not be decoded using the default
* schema.
@@ -353,7 +344,7 @@
* @throws NullPointerException
* If {@code name} or {@code password} was {@code null}.
*/
- BindResult bind(String name, char[] password) throws ErrorResultException, InterruptedException;
+ BindResult bind(String name, char[] password) throws ErrorResultException;
/**
* Asynchronously authenticates to the Directory Server using the provided
@@ -436,8 +427,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support compare operations.
* @throws IllegalStateException
@@ -446,7 +435,7 @@
* @throws NullPointerException
* If {@code request} was {@code null}.
*/
- CompareResult compare(CompareRequest request) throws ErrorResultException, InterruptedException;
+ CompareResult compare(CompareRequest request) throws ErrorResultException;
/**
* Compares the named entry in the Directory Server against the provided
@@ -469,8 +458,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws LocalizedIllegalArgumentException
* If {@code name} or {@code AttributeDescription} could not be
* decoded using the default schema.
@@ -484,7 +471,7 @@
* {@code assertionValue} was {@code null}.
*/
CompareResult compare(String name, String attributeDescription, String assertionValue)
- throws ErrorResultException, InterruptedException;
+ throws ErrorResultException;
/**
* Asynchronously compares an entry in the Directory Server using the
@@ -522,8 +509,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support delete operations.
* @throws IllegalStateException
@@ -532,7 +517,7 @@
* @throws NullPointerException
* If {@code request} was {@code null}.
*/
- Result delete(DeleteRequest request) throws ErrorResultException, InterruptedException;
+ Result delete(DeleteRequest request) throws ErrorResultException;
/**
* Deletes the named entry from the Directory Server.
@@ -550,8 +535,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws LocalizedIllegalArgumentException
* If {@code name} could not be decoded using the default
* schema.
@@ -563,7 +546,7 @@
* @throws NullPointerException
* If {@code name} was {@code null}.
*/
- Result delete(String name) throws ErrorResultException, InterruptedException;
+ Result delete(String name) throws ErrorResultException;
/**
* Asynchronously deletes an entry from the Directory Server using the
@@ -603,8 +586,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support extended operations.
* @throws IllegalStateException
@@ -614,7 +595,7 @@
* If {@code request} was {@code null}.
*/
<R extends ExtendedResult> R extendedRequest(ExtendedRequest<R> request)
- throws ErrorResultException, InterruptedException;
+ throws ErrorResultException;
/**
* Requests that the Directory Server performs the provided extended
@@ -632,8 +613,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support extended operations.
* @throws IllegalStateException
@@ -643,7 +622,7 @@
* If {@code request} was {@code null}.
*/
<R extends ExtendedResult> R extendedRequest(ExtendedRequest<R> request,
- IntermediateResponseHandler handler) throws ErrorResultException, InterruptedException;
+ IntermediateResponseHandler handler) throws ErrorResultException;
/**
* Requests that the Directory Server performs the provided extended
@@ -666,8 +645,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support extended operations.
* @throws IllegalStateException
@@ -677,7 +654,7 @@
* If {@code requestName} was {@code null}.
*/
GenericExtendedResult extendedRequest(String requestName, ByteString requestValue)
- throws ErrorResultException, InterruptedException;
+ throws ErrorResultException;
/**
* Asynchronously performs the provided extended request in the Directory
@@ -739,8 +716,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support modify operations.
* @throws IllegalStateException
@@ -749,7 +724,7 @@
* @throws NullPointerException
* If {@code request} was {@code null}.
*/
- Result modify(ModifyRequest request) throws ErrorResultException, InterruptedException;
+ Result modify(ModifyRequest request) throws ErrorResultException;
/**
* Modifies an entry in the Directory Server using the provided lines of
@@ -769,8 +744,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support modify operations.
* @throws LocalizedIllegalArgumentException
@@ -782,7 +755,7 @@
* @throws NullPointerException
* If {@code ldifLines} was {@code null} .
*/
- Result modify(String... ldifLines) throws ErrorResultException, InterruptedException;
+ Result modify(String... ldifLines) throws ErrorResultException;
/**
* Asynchronously modifies an entry in the Directory Server using the
@@ -820,8 +793,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support modify DN operations.
* @throws IllegalStateException
@@ -830,7 +801,7 @@
* @throws NullPointerException
* If {@code request} was {@code null}.
*/
- Result modifyDN(ModifyDNRequest request) throws ErrorResultException, InterruptedException;
+ Result modifyDN(ModifyDNRequest request) throws ErrorResultException;
/**
* Renames the named entry in the Directory Server using the provided new
@@ -851,8 +822,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws LocalizedIllegalArgumentException
* If {@code name} or {@code newRDN} could not be decoded using
* the default schema.
@@ -864,7 +833,7 @@
* @throws NullPointerException
* If {@code name} or {@code newRDN} was {@code null}.
*/
- Result modifyDN(String name, String newRDN) throws ErrorResultException, InterruptedException;
+ Result modifyDN(String name, String newRDN) throws ErrorResultException;
/**
* Asynchronously renames an entry in the Directory Server using the
@@ -917,8 +886,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support search operations.
* @throws IllegalStateException
@@ -928,7 +895,7 @@
* If the {@code name} was {@code null}.
*/
SearchResultEntry readEntry(DN name, String... attributeDescriptions)
- throws ErrorResultException, InterruptedException;
+ throws ErrorResultException;
/**
* Reads the named entry from the Directory Server.
@@ -953,8 +920,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws LocalizedIllegalArgumentException
* If {@code baseObject} could not be decoded using the default
* schema.
@@ -967,7 +932,7 @@
* If the {@code name} was {@code null}.
*/
SearchResultEntry readEntry(String name, String... attributeDescriptions)
- throws ErrorResultException, InterruptedException;
+ throws ErrorResultException;
/**
* Asynchronously reads the named entry from the Directory Server.
@@ -1069,8 +1034,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support search operations.
* @throws IllegalStateException
@@ -1080,7 +1043,7 @@
* If {@code request} or {@code entries} was {@code null}.
*/
Result search(SearchRequest request, Collection<? super SearchResultEntry> entries)
- throws ErrorResultException, InterruptedException;
+ throws ErrorResultException;
/**
* Searches the Directory Server using the provided search request. Any
@@ -1105,8 +1068,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support search operations.
* @throws IllegalStateException
@@ -1116,8 +1077,7 @@
* If {@code request} or {@code entries} was {@code null}.
*/
Result search(SearchRequest request, Collection<? super SearchResultEntry> entries,
- Collection<? super SearchResultReference> references) throws ErrorResultException,
- InterruptedException;
+ Collection<? super SearchResultReference> references) throws ErrorResultException;
/**
* Searches the Directory Server using the provided search request. Any
@@ -1134,8 +1094,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support search operations.
* @throws IllegalStateException
@@ -1144,8 +1102,7 @@
* @throws NullPointerException
* If {@code request} was {@code null}.
*/
- Result search(SearchRequest request, SearchResultHandler handler) throws ErrorResultException,
- InterruptedException;
+ Result search(SearchRequest request, SearchResultHandler handler) throws ErrorResultException;
/**
* Searches the Directory Server using the provided search parameters. Any
@@ -1229,8 +1186,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If this connection does not support search operations.
* @throws IllegalStateException
@@ -1239,8 +1194,7 @@
* @throws NullPointerException
* If the {@code request} was {@code null}.
*/
- SearchResultEntry searchSingleEntry(SearchRequest request) throws ErrorResultException,
- InterruptedException;
+ SearchResultEntry searchSingleEntry(SearchRequest request) throws ErrorResultException;
/**
* Searches the Directory Server for a single entry using the provided
@@ -1273,8 +1227,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws LocalizedIllegalArgumentException
* If {@code baseObject} could not be decoded using the default
* schema or if {@code filter} is not a valid LDAP string
@@ -1289,7 +1241,7 @@
* were {@code null}.
*/
SearchResultEntry searchSingleEntry(String baseObject, SearchScope scope, String filter,
- String... attributeDescriptions) throws ErrorResultException, InterruptedException;
+ String... attributeDescriptions) throws ErrorResultException;
/**
* Asynchronously searches the Directory Server for a single entry using the
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java
index b5b1ccf..3be6d5c 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionFactory.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS.
+ * Portions copyright 2011-2012 ForgeRock AS.
*/
package org.forgerock.opendj.ldap;
@@ -68,13 +68,16 @@
* Returns a connection to the Directory Server associated with this
* connection factory. The connection returned by this method can be used
* immediately.
+ * <p>
+ * If the calling thread is interrupted while waiting for the connection
+ * attempt to complete then the calling thread unblock and throw a
+ * {@link CancelledResultException} whose cause is the underlying
+ * {@link InterruptedException}.
*
* @return A connection to the Directory Server associated with this
* connection factory.
* @throws ErrorResultException
* If the connection request failed for some reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
*/
- Connection getConnection() throws ErrorResultException, InterruptedException;
+ Connection getConnection() throws ErrorResultException;
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionPool.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionPool.java
index f06fe8d..98e574e 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionPool.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ConnectionPool.java
@@ -21,7 +21,7 @@
* CDDL HEADER END
*
*
- * Copyright 2011 ForgeRock AS
+ * Copyright 2011-2012 ForgeRock AS
*/
package org.forgerock.opendj.ldap;
@@ -86,10 +86,8 @@
* @return A pooled connection.
* @throws ErrorResultException
* If the connection request failed for some reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws IllegalStateException
* If this connection pool has already been closed.
*/
- Connection getConnection() throws ErrorResultException, InterruptedException;
+ Connection getConnection() throws ErrorResultException;
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connections.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connections.java
index 1c1d042..c892cbb 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connections.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/Connections.java
@@ -262,7 +262,7 @@
}
@Override
- public Connection getConnection() throws ErrorResultException, InterruptedException {
+ public Connection getConnection() throws ErrorResultException {
return factory.getConnection();
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ErrorResultException.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ErrorResultException.java
index b479697..be4274d 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ErrorResultException.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/ErrorResultException.java
@@ -193,7 +193,7 @@
* The error result.
*/
protected ErrorResultException(final Result result) {
- super(result.getResultCode() + ": " + result.getDiagnosticMessage());
+ super(result.getResultCode() + ": " + result.getDiagnosticMessage(), result.getCause());
this.result = result;
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FixedConnectionPool.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FixedConnectionPool.java
index 04227a7..0dba2fb 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FixedConnectionPool.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/FixedConnectionPool.java
@@ -28,6 +28,7 @@
package org.forgerock.opendj.ldap;
import static org.forgerock.opendj.ldap.CoreMessages.ERR_CONNECTION_POOL_CLOSING;
+import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import java.util.Collection;
import java.util.LinkedList;
@@ -122,9 +123,8 @@
* connections are not actually stored in the internal queue.
*/
private final class PooledConnection implements Connection {
- // Connection event listeners registed against this pooled connection
- // should
- // have the same life time as the pooled connection.
+ // Connection event listeners registered against this pooled connection
+ // should have the same life time as the pooled connection.
private final List<ConnectionEventListener> listeners =
new CopyOnWriteArrayList<ConnectionEventListener>();
@@ -142,19 +142,17 @@
}
@Override
- public Result add(final AddRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result add(final AddRequest request) throws ErrorResultException {
return checkState().add(request);
}
@Override
- public Result add(final Entry entry) throws ErrorResultException, InterruptedException {
+ public Result add(final Entry entry) throws ErrorResultException {
return checkState().add(entry);
}
@Override
- public Result add(final String... ldifLines) throws ErrorResultException,
- InterruptedException {
+ public Result add(final String... ldifLines) throws ErrorResultException {
return checkState().add(ldifLines);
}
@@ -176,14 +174,13 @@
}
@Override
- public BindResult bind(final BindRequest request) throws ErrorResultException,
- InterruptedException {
+ public BindResult bind(final BindRequest request) throws ErrorResultException {
return checkState().bind(request);
}
@Override
public BindResult bind(final String name, final char[] password)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return checkState().bind(name, password);
}
@@ -209,11 +206,9 @@
publishConnection(connection);
} else {
// The connection may have been disconnected by the remote
- // server, but
- // the server may still be available. In order to avoid leaving
- // pending
- // futures hanging indefinitely, we should try to reconnect
- // immediately.
+ // server, but the server may still be available. In order to
+ // avoid leaving pending futures hanging indefinitely, we should
+ // try to reconnect immediately.
// Close the dead connection.
connection.close();
@@ -238,14 +233,13 @@
}
@Override
- public CompareResult compare(final CompareRequest request) throws ErrorResultException,
- InterruptedException {
+ public CompareResult compare(final CompareRequest request) throws ErrorResultException {
return checkState().compare(request);
}
@Override
public CompareResult compare(final String name, final String attributeDescription,
- final String assertionValue) throws ErrorResultException, InterruptedException {
+ final String assertionValue) throws ErrorResultException {
return checkState().compare(name, attributeDescription, assertionValue);
}
@@ -257,13 +251,12 @@
}
@Override
- public Result delete(final DeleteRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result delete(final DeleteRequest request) throws ErrorResultException {
return checkState().delete(request);
}
@Override
- public Result delete(final String name) throws ErrorResultException, InterruptedException {
+ public Result delete(final String name) throws ErrorResultException {
return checkState().delete(name);
}
@@ -276,20 +269,19 @@
@Override
public <R extends ExtendedResult> R extendedRequest(final ExtendedRequest<R> request)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return checkState().extendedRequest(request);
}
@Override
public <R extends ExtendedResult> R extendedRequest(final ExtendedRequest<R> request,
- final IntermediateResponseHandler handler) throws ErrorResultException,
- InterruptedException {
+ final IntermediateResponseHandler handler) throws ErrorResultException {
return checkState().extendedRequest(request, handler);
}
@Override
public GenericExtendedResult extendedRequest(final String requestName,
- final ByteString requestValue) throws ErrorResultException, InterruptedException {
+ final ByteString requestValue) throws ErrorResultException {
return checkState().extendedRequest(requestName, requestValue);
}
@@ -319,14 +311,12 @@
}
@Override
- public Result modify(final ModifyRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result modify(final ModifyRequest request) throws ErrorResultException {
return checkState().modify(request);
}
@Override
- public Result modify(final String... ldifLines) throws ErrorResultException,
- InterruptedException {
+ public Result modify(final String... ldifLines) throws ErrorResultException {
return checkState().modify(ldifLines);
}
@@ -338,14 +328,12 @@
}
@Override
- public Result modifyDN(final ModifyDNRequest request) throws ErrorResultException,
- InterruptedException {
+ public Result modifyDN(final ModifyDNRequest request) throws ErrorResultException {
return checkState().modifyDN(request);
}
@Override
- public Result modifyDN(final String name, final String newRDN) throws ErrorResultException,
- InterruptedException {
+ public Result modifyDN(final String name, final String newRDN) throws ErrorResultException {
return checkState().modifyDN(name, newRDN);
}
@@ -358,13 +346,13 @@
@Override
public SearchResultEntry readEntry(final DN name, final String... attributeDescriptions)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return checkState().readEntry(name, attributeDescriptions);
}
@Override
public SearchResultEntry readEntry(final String name, final String... attributeDescriptions)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return checkState().readEntry(name, attributeDescriptions);
}
@@ -392,8 +380,7 @@
@Override
public Result search(final SearchRequest request,
- final Collection<? super SearchResultEntry> entries) throws ErrorResultException,
- InterruptedException {
+ final Collection<? super SearchResultEntry> entries) throws ErrorResultException {
return checkState().search(request, entries);
}
@@ -401,13 +388,13 @@
public Result search(final SearchRequest request,
final Collection<? super SearchResultEntry> entries,
final Collection<? super SearchResultReference> references)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return checkState().search(request, entries, references);
}
@Override
public Result search(final SearchRequest request, final SearchResultHandler handler)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return checkState().search(request, handler);
}
@@ -426,14 +413,14 @@
@Override
public SearchResultEntry searchSingleEntry(final SearchRequest request)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return checkState().searchSingleEntry(request);
}
@Override
public SearchResultEntry searchSingleEntry(final String baseObject,
final SearchScope scope, final String filter, final String... attributeDescriptions)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return checkState().searchSingleEntry(baseObject, scope, filter, attributeDescriptions);
}
@@ -550,8 +537,7 @@
isClosed = true;
// Remove any connections which are waiting in the queue as these
- // can be
- // closed immediately.
+ // can be closed immediately.
idleConnections = new LinkedList<Connection>();
while (!queue.isEmpty() && !queue.getFirst().isWaitingFuture()) {
final QueueElement holder = queue.removeFirst();
@@ -575,8 +561,12 @@
* {@inheritDoc}
*/
@Override
- public Connection getConnection() throws ErrorResultException, InterruptedException {
- return getConnectionAsync(null).get();
+ public Connection getConnection() throws ErrorResultException {
+ try {
+ return getConnectionAsync(null).get();
+ } catch (InterruptedException e) {
+ throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e);
+ }
}
/**
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/HeartBeatConnectionFactory.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/HeartBeatConnectionFactory.java
index fc61d8c..9a36dba 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/HeartBeatConnectionFactory.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/HeartBeatConnectionFactory.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2009-2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS.
+ * Portions copyright 2011-2012 ForgeRock AS.
*/
package org.forgerock.opendj.ldap;
@@ -289,7 +289,7 @@
* {@inheritDoc}
*/
@Override
- public Connection getConnection() throws ErrorResultException, InterruptedException {
+ public Connection getConnection() throws ErrorResultException {
return adaptConnection(factory.getConnection());
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/InternalConnectionFactory.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/InternalConnectionFactory.java
index b7123cf..ceaac3c 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/InternalConnectionFactory.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/InternalConnectionFactory.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS.
+ * Portions copyright 2011-2012 ForgeRock AS.
*/
package org.forgerock.opendj.ldap;
@@ -64,7 +64,7 @@
/**
* {@inheritDoc}
*/
- public Connection getConnection() throws ErrorResultException, InterruptedException {
+ public Connection getConnection() throws ErrorResultException {
final ServerConnection<Integer> serverConnection = factory.handleAccept(clientContext);
return new InternalConnection(serverConnection);
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java
index 5660398..0e7655d 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LDAPConnectionFactory.java
@@ -40,8 +40,7 @@
*/
public final class LDAPConnectionFactory implements ConnectionFactory {
// We implement the factory using the pimpl idiom in order to avoid making
- // too
- // many implementation classes public.
+ // too many implementation classes public.
private final LDAPConnectionFactoryImpl impl;
@@ -139,7 +138,7 @@
* {@inheritDoc}
*/
@Override
- public Connection getConnection() throws ErrorResultException, InterruptedException {
+ public Connection getConnection() throws ErrorResultException {
return impl.getConnection();
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LoadBalancer.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LoadBalancer.java
index 1c65d0d..2b59286 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LoadBalancer.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/LoadBalancer.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS.
+ * Portions copyright 2011-2012 ForgeRock AS.
*/
package org.forgerock.opendj.ldap;
@@ -52,7 +52,7 @@
/**
* {@inheritDoc}
*/
- public Connection getConnection() throws ErrorResultException, InterruptedException {
+ public Connection getConnection() throws ErrorResultException {
return algorithm.getConnectionFactory().getConnection();
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RootDSE.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RootDSE.java
index 861e913..4979a86 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RootDSE.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/RootDSE.java
@@ -181,8 +181,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If the connection does not support search operations.
* @throws IllegalStateException
@@ -191,8 +189,7 @@
* @throws NullPointerException
* If the {@code connection} was {@code null}.
*/
- public static RootDSE readRootDSE(final Connection connection) throws ErrorResultException,
- InterruptedException {
+ public static RootDSE readRootDSE(final Connection connection) throws ErrorResultException {
final Entry entry = connection.searchSingleEntry(SEARCH_REQUEST);
return valueOf(entry);
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
index 303f04e..14e967e 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/Schema.java
@@ -1184,8 +1184,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If the connection does not support search operations.
* @throws IllegalStateException
@@ -1195,7 +1193,7 @@
* If the {@code connection} or {@code name} was {@code null}.
*/
public static Schema readSchema(final Connection connection, final DN name)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return new SchemaBuilder().addSchema(connection, name, true).toSchema();
}
@@ -1276,8 +1274,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If the connection does not support search operations.
* @throws IllegalStateException
@@ -1287,7 +1283,7 @@
* If the {@code connection} or {@code name} was {@code null}.
*/
public static Schema readSchemaForEntry(final Connection connection, final DN name)
- throws ErrorResultException, InterruptedException {
+ throws ErrorResultException {
return new SchemaBuilder().addSchemaForEntry(connection, name, true).toSchema();
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
index fc3589a..24e6a26 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldap/schema/SchemaBuilder.java
@@ -1779,8 +1779,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If the connection does not support search operations.
* @throws IllegalStateException
@@ -1790,7 +1788,7 @@
* If the {@code connection} or {@code name} was {@code null}.
*/
public SchemaBuilder addSchema(final Connection connection, final DN name,
- final boolean overwrite) throws ErrorResultException, InterruptedException {
+ final boolean overwrite) throws ErrorResultException {
// The call to addSchema will perform copyOnWrite.
final SearchRequest request = getReadSchemaSearchRequest(name);
final Entry entry = connection.searchSingleEntry(request);
@@ -2018,8 +2016,6 @@
* @throws ErrorResultException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedException
- * If the current thread was interrupted while waiting.
* @throws UnsupportedOperationException
* If the connection does not support search operations.
* @throws IllegalStateException
@@ -2029,7 +2025,7 @@
* If the {@code connection} or {@code name} was {@code null}.
*/
public SchemaBuilder addSchemaForEntry(final Connection connection, final DN name,
- final boolean overwrite) throws ErrorResultException, InterruptedException {
+ final boolean overwrite) throws ErrorResultException {
// The call to addSchema will perform copyOnWrite.
final SearchRequest request = getReadSchemaForEntrySearchRequest(name);
final Entry entry = connection.searchSingleEntry(request);
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionChangeRecordWriter.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionChangeRecordWriter.java
index b6432de..94559ea 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionChangeRecordWriter.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionChangeRecordWriter.java
@@ -28,7 +28,6 @@
package org.forgerock.opendj.ldif;
import java.io.IOException;
-import java.io.InterruptedIOException;
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ErrorResultException;
@@ -98,20 +97,16 @@
* @throws ErrorResultIOException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NullPointerException
* If {@code change} was {@code null}.
*/
public ConnectionChangeRecordWriter writeChangeRecord(final AddRequest change)
- throws ErrorResultIOException, InterruptedIOException {
+ throws ErrorResultIOException {
Validator.ensureNotNull(change);
try {
connection.add(change);
} catch (final ErrorResultException e) {
throw new ErrorResultIOException(e);
- } catch (final InterruptedException e) {
- throw new InterruptedIOException(e.getMessage());
}
return this;
}
@@ -126,13 +121,11 @@
* @throws ErrorResultIOException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NullPointerException
* If {@code change} was {@code null}.
*/
public ConnectionChangeRecordWriter writeChangeRecord(final ChangeRecord change)
- throws ErrorResultIOException, InterruptedIOException {
+ throws ErrorResultIOException {
Validator.ensureNotNull(change);
final IOException e = change.accept(ChangeRecordVisitorWriter.getInstance(), this);
@@ -142,8 +135,6 @@
}
} catch (final ErrorResultIOException e1) {
throw e1;
- } catch (final InterruptedIOException e1) {
- throw e1;
} catch (final IOException e1) {
// Should not happen.
throw new RuntimeException(e1);
@@ -161,20 +152,16 @@
* @throws ErrorResultIOException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NullPointerException
* If {@code change} was {@code null}.
*/
public ConnectionChangeRecordWriter writeChangeRecord(final DeleteRequest change)
- throws ErrorResultIOException, InterruptedIOException {
+ throws ErrorResultIOException {
Validator.ensureNotNull(change);
try {
connection.delete(change);
} catch (final ErrorResultException e) {
throw new ErrorResultIOException(e);
- } catch (final InterruptedException e) {
- throw new InterruptedIOException(e.getMessage());
}
return this;
}
@@ -189,20 +176,16 @@
* @throws ErrorResultIOException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NullPointerException
* If {@code change} was {@code null}.
*/
public ConnectionChangeRecordWriter writeChangeRecord(final ModifyDNRequest change)
- throws ErrorResultIOException, InterruptedIOException {
+ throws ErrorResultIOException {
Validator.ensureNotNull(change);
try {
connection.modifyDN(change);
} catch (final ErrorResultException e) {
throw new ErrorResultIOException(e);
- } catch (final InterruptedException e) {
- throw new InterruptedIOException(e.getMessage());
}
return this;
}
@@ -217,20 +200,16 @@
* @throws ErrorResultIOException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NullPointerException
* If {@code change} was {@code null}.
*/
public ConnectionChangeRecordWriter writeChangeRecord(final ModifyRequest change)
- throws ErrorResultIOException, InterruptedIOException {
+ throws ErrorResultIOException {
Validator.ensureNotNull(change);
try {
connection.modify(change);
} catch (final ErrorResultException e) {
throw new ErrorResultIOException(e);
- } catch (final InterruptedException e) {
- throw new InterruptedIOException(e.getMessage());
}
return this;
}
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java
index 39c3129..d1fa617 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryReader.java
@@ -29,7 +29,6 @@
import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
-import java.io.InterruptedIOException;
import java.util.NoSuchElementException;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
@@ -121,7 +120,6 @@
// Prevent the reader from waiting for a result that will never
// arrive.
isInterrupted = true;
-
Thread.currentThread().interrupt();
return false;
}
@@ -135,7 +133,6 @@
// Prevent the reader from waiting for a result that will never
// arrive.
isInterrupted = true;
-
Thread.currentThread().interrupt();
}
}
@@ -149,7 +146,6 @@
// Prevent the reader from waiting for a result that will never
// arrive.
isInterrupted = true;
-
Thread.currentThread().interrupt();
return false;
}
@@ -163,7 +159,6 @@
// Prevent the reader from waiting for a result that will never
// arrive.
isInterrupted = true;
-
Thread.currentThread().interrupt();
}
}
@@ -210,7 +205,7 @@
}
/**
- * Closes this connection entry reader, cancelling the search request if it
+ * Closes this connection entry reader, canceling the search request if it
* is still active.
*/
@Override
@@ -223,7 +218,7 @@
* {@inheritDoc}
*/
@Override
- public boolean hasNext() throws ErrorResultIOException, InterruptedIOException {
+ public boolean hasNext() throws ErrorResultIOException {
// Poll for the next response if needed.
final Response r = getNextResponse();
if (!(r instanceof Result)) {
@@ -251,14 +246,12 @@
* If there are no more search result entries or references and
* the search result code indicates that the search operation
* failed for some reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NoSuchElementException
* If there are no more search result entries or references and
* the search result code indicates that the search operation
* succeeded.
*/
- public boolean isEntry() throws ErrorResultIOException, InterruptedIOException {
+ public boolean isEntry() throws ErrorResultIOException {
// Throws ErrorResultIOException if search returned error.
if (!hasNext()) {
// Search has completed successfully.
@@ -287,14 +280,12 @@
* If there are no more search result entries or references and
* the search result code indicates that the search operation
* failed for some reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NoSuchElementException
* If there are no more search result entries or references and
* the search result code indicates that the search operation
* succeeded.
*/
- public boolean isReference() throws ErrorResultIOException, InterruptedIOException {
+ public boolean isReference() throws ErrorResultIOException {
return !isEntry();
}
@@ -314,8 +305,6 @@
* If there are no more search result entries or references and
* the search result code indicates that the search operation
* failed for some reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NoSuchElementException
* If there are no more search result entries or references and
* the search result code indicates that the search operation
@@ -323,7 +312,7 @@
*/
@Override
public SearchResultEntry readEntry() throws SearchResultReferenceIOException,
- ErrorResultIOException, InterruptedIOException {
+ ErrorResultIOException {
if (isEntry()) {
final SearchResultEntry entry = (SearchResultEntry) nextResponse;
nextResponse = null;
@@ -347,15 +336,12 @@
* If there are no more search result entries or references and
* the search result code indicates that the search operation
* failed for some reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NoSuchElementException
* If there are no more search result entries or references and
* the search result code indicates that the search operation
* succeeded.
*/
- public SearchResultReference readReference() throws ErrorResultIOException,
- InterruptedIOException {
+ public SearchResultReference readReference() throws ErrorResultIOException {
if (isReference()) {
final SearchResultReference reference = (SearchResultReference) nextResponse;
nextResponse = null;
@@ -365,12 +351,14 @@
}
}
- private Response getNextResponse() throws InterruptedIOException {
+ private Response getNextResponse() throws ErrorResultIOException {
while (nextResponse == null) {
try {
nextResponse = buffer.responses.poll(50, TimeUnit.MILLISECONDS);
} catch (final InterruptedException e) {
- throw new InterruptedIOException(e.getMessage());
+ final ErrorResultException ere =
+ newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e);
+ throw new ErrorResultIOException(ere);
}
if (nextResponse == null && buffer.isInterrupted) {
diff --git a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryWriter.java b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryWriter.java
index 7960a5d..63abe9f 100644
--- a/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryWriter.java
+++ b/opendj3/opendj-ldap-sdk/src/main/java/org/forgerock/opendj/ldif/ConnectionEntryWriter.java
@@ -27,8 +27,6 @@
package org.forgerock.opendj.ldif;
-import java.io.InterruptedIOException;
-
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.Entry;
import org.forgerock.opendj.ldap.ErrorResultException;
@@ -109,20 +107,15 @@
* @throws ErrorResultIOException
* If the result code indicates that the request failed for some
* reason.
- * @throws InterruptedIOException
- * If the current thread was interrupted while waiting.
* @throws NullPointerException
* If {@code entry} was {@code null}.
*/
- public ConnectionEntryWriter writeEntry(final Entry entry) throws ErrorResultIOException,
- InterruptedIOException {
+ public ConnectionEntryWriter writeEntry(final Entry entry) throws ErrorResultIOException {
Validator.ensureNotNull(entry);
try {
connection.add(entry);
} catch (final ErrorResultException e) {
throw new ErrorResultIOException(e);
- } catch (final InterruptedException e) {
- throw new InterruptedIOException(e.getMessage());
}
return this;
}
diff --git a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPListenerTestCase.java b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPListenerTestCase.java
index 21b9356..a8e13d2 100644
--- a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPListenerTestCase.java
+++ b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/LDAPListenerTestCase.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS.
+ * Portions copyright 2011-2012 ForgeRock AS.
*/
package org.forgerock.opendj.ldap;
@@ -504,15 +504,9 @@
public ServerConnection<Integer> handleAccept(
final LDAPClientContext clientContext) throws ErrorResultException {
// Get connection from load balancer, this should
- // fail over twice
- // before getting connection to online server.
- try {
- loadBalancer.getConnection().close();
- } catch (final InterruptedException e) {
- // Unexpected.
- throw ErrorResultException.newErrorResult(ResultCode.OTHER,
- "Unexpected exception when connecting to online server", e);
- }
+ // fail over twice before getting connection to
+ // online server.
+ loadBalancer.getConnection().close();
return super.handleAccept(clientContext);
}
diff --git a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java
index b320b42..e147ecb 100644
--- a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java
+++ b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/AuthenticatedConnectionFactory.java
@@ -88,16 +88,14 @@
/**
* {@inheritDoc}
*/
- public BindResult bind(BindRequest request) throws ErrorResultException,
- InterruptedException {
+ public BindResult bind(BindRequest request) throws ErrorResultException {
throw new UnsupportedOperationException();
}
/**
* {@inheritDoc}
*/
- public BindResult bind(String name, char[] password) throws ErrorResultException,
- InterruptedException {
+ public BindResult bind(String name, char[] password) throws ErrorResultException {
throw new UnsupportedOperationException();
}
@@ -260,7 +258,7 @@
/**
* {@inheritDoc}
*/
- public Connection getConnection() throws ErrorResultException, InterruptedException {
+ public Connection getConnection() throws ErrorResultException {
final Connection connection = parentFactory.getConnection();
BindResult bindResult = null;
try {
@@ -271,8 +269,7 @@
}
}
// If the bind didn't succeed then an exception will have been thrown
- // and
- // this line will not be reached.
+ // and this line will not be reached.
return new AuthenticatedConnection(connection, request, bindResult);
}
diff --git a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java
index 446d876..c4eb763 100644
--- a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java
+++ b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPCompare.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2012 ForgeRock AS
*/
package com.forgerock.opendj.ldap.tools;
@@ -30,7 +30,6 @@
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
-import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
@@ -92,17 +91,7 @@
request.getAssertionValueAsString(), request.getName().toString()));
if (connection != null) {
try {
- Result result;
- try {
- result = connection.compare(request);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other threads
- // to
- // interrupt this one.
- throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e
- .getLocalizedMessage(), e);
- }
-
+ Result result = connection.compare(request);
if (result.getResultCode() == ResultCode.COMPARE_FALSE) {
println(INFO_COMPARE_OPERATION_RESULT_FALSE.get(request.getName().toString()));
} else {
@@ -391,11 +380,6 @@
} catch (final ErrorResultException ere) {
println(LocalizableMessage.raw(ere.getMessage()));
return ere.getResult().getResultCode().intValue();
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other threads to
- // interrupt this one.
- println(LocalizableMessage.raw(e.getLocalizedMessage()));
- return ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue();
}
}
diff --git a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
index 9bed33d..cf9dbb4 100644
--- a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
+++ b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPModify.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2012 ForgeRock AS
*/
package com.forgerock.opendj.ldap.tools;
@@ -30,7 +30,6 @@
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
-import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import java.io.FileInputStream;
import java.io.IOException;
@@ -81,16 +80,7 @@
println(INFO_PROCESSING_OPERATION.get(opType, change.getName().toString()));
if (connection != null) {
try {
- Result r;
- try {
- r = connection.add(change);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other
- // threads
- // to interrupt this one.
- throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e
- .getLocalizedMessage(), e);
- }
+ Result r = connection.add(change);
printResult(opType, change.getName().toString(), r);
return r.getResultCode().intValue();
} catch (final ErrorResultException ere) {
@@ -108,16 +98,7 @@
println(INFO_PROCESSING_OPERATION.get(opType, change.getName().toString()));
if (connection != null) {
try {
- Result r;
- try {
- r = connection.delete(change);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other
- // threads
- // to interrupt this one.
- throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e
- .getLocalizedMessage(), e);
- }
+ Result r = connection.delete(change);
printResult(opType, change.getName().toString(), r);
return r.getResultCode().intValue();
} catch (final ErrorResultException ere) {
@@ -135,16 +116,7 @@
println(INFO_PROCESSING_OPERATION.get(opType, change.getName().toString()));
if (connection != null) {
try {
- Result r;
- try {
- r = connection.modifyDN(change);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other
- // threads
- // to interrupt this one.
- throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e
- .getLocalizedMessage(), e);
- }
+ Result r = connection.modifyDN(change);
printResult(opType, change.getName().toString(), r);
return r.getResultCode().intValue();
} catch (final ErrorResultException ere) {
@@ -162,16 +134,7 @@
println(INFO_PROCESSING_OPERATION.get(opType, change.getName().toString()));
if (connection != null) {
try {
- Result r;
- try {
- r = connection.modify(change);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other
- // threads
- // to interrupt this one.
- throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e
- .getLocalizedMessage(), e);
- }
+ Result r = connection.modify(change);
printResult(opType, change.getName().toString(), r);
return r.getResultCode().intValue();
} catch (final ErrorResultException ere) {
@@ -501,11 +464,6 @@
connection = connectionFactory.getConnection();
} catch (final ErrorResultException ere) {
return Utils.printErrorMessage(this, ere);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other threads to
- // interrupt this one.
- println(LocalizableMessage.raw(e.getLocalizedMessage()));
- return ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue();
}
}
diff --git a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
index 17b2cef..22762e6 100644
--- a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
+++ b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPPasswordModify.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2012 ForgeRock AS
*/
package com.forgerock.opendj.ldap.tools;
@@ -30,7 +30,6 @@
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
-import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import org.forgerock.i18n.LocalizableMessage;
import org.forgerock.opendj.ldap.ByteString;
@@ -249,11 +248,6 @@
connection = connectionFactory.getConnection();
} catch (final ErrorResultException ere) {
return Utils.printErrorMessage(this, ere);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other threads to
- // interrupt this one.
- println(LocalizableMessage.raw(e.getLocalizedMessage()));
- return ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue();
}
if (proxyAuthzID.isPresent()) {
@@ -274,14 +268,7 @@
PasswordModifyExtendedResult result;
try {
- try {
- result = connection.extendedRequest(request);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other threads to
- // interrupt this one.
- throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED,
- e.getLocalizedMessage(), e);
- }
+ result = connection.extendedRequest(request);
} catch (final ErrorResultException e) {
LocalizableMessage message =
ERR_LDAPPWMOD_FAILED.get(e.getResult().getResultCode().intValue(), e
diff --git a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
index 27b8331..dfa65b0 100644
--- a/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
+++ b/opendj3/opendj-ldap-toolkit/src/main/java/com/forgerock/opendj/ldap/tools/LDAPSearch.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2010 Sun Microsystems, Inc.
- * Portions copyright 2011 ForgeRock AS
+ * Portions copyright 2011-2012 ForgeRock AS
*/
package com.forgerock.opendj.ldap.tools;
@@ -30,7 +30,6 @@
import static com.forgerock.opendj.ldap.tools.ToolConstants.*;
import static com.forgerock.opendj.ldap.tools.ToolsMessages.*;
import static com.forgerock.opendj.ldap.tools.Utils.filterExitCode;
-import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import java.io.BufferedReader;
import java.io.FileReader;
@@ -846,11 +845,6 @@
connection = connectionFactory.getConnection();
} catch (final ErrorResultException ere) {
return Utils.printErrorMessage(this, ere);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other threads to
- // interrupt this one.
- println(LocalizableMessage.raw(e.getLocalizedMessage()));
- return ResultCode.CLIENT_SIDE_USER_CANCELLED.intValue();
}
Utils.printPasswordPolicyResults(this, connection);
@@ -860,17 +854,7 @@
ldifWriter = new LDIFEntryWriter(getOutputStream()).setWrapColumn(wrapColumn);
final LDAPSearchResultHandler resultHandler = new LDAPSearchResultHandler();
while (true) {
- Result result;
- try {
- result = connection.search(search, resultHandler);
- } catch (final InterruptedException e) {
- // This shouldn't happen because there are no other threads
- // to
- // interrupt this one.
- throw newErrorResult(ResultCode.CLIENT_SIDE_USER_CANCELLED, e
- .getLocalizedMessage(), e);
- }
-
+ Result result = connection.search(search, resultHandler);
try {
final ServerSideSortResponseControl control =
result.getControl(ServerSideSortResponseControl.DECODER,
--
Gitblit v1.10.0