mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
28.26.2014 277458ff82e58a0d0542916e4d8386caf29c143e
Additional fix for OPENDJ-1197: API is lacking functionality to specify TCP connect timeout

* throw a connect error when a connection attempt times out instead of a timeout error, as it seems more appropriate.

2 files modified
8 ■■■■■ changed files
opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactory.java 2 ●●● patch | view | raw | blame | history
opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactoryTestCase.java 6 ●●●●● patch | view | raw | blame | history
opendj-grizzly/src/main/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactory.java
@@ -216,7 +216,7 @@
            } else if (timeoutEndTime > currentTime) {
                return timeoutEndTime - currentTime;
            } else {
                future.handleErrorResult(newErrorResult(ResultCode.CLIENT_SIDE_TIMEOUT,
                future.handleErrorResult(newErrorResult(ResultCode.CLIENT_SIDE_CONNECT_ERROR,
                        LDAP_CONNECTION_CONNECT_TIMEOUT.get(socketAddress, getTimeout()).toString()));
                return 0;
            }
opendj-grizzly/src/test/java/org/forgerock/opendj/grizzly/GrizzlyLDAPConnectionFactoryTestCase.java
@@ -42,6 +42,7 @@
import org.forgerock.opendj.ldap.Connection;
import org.forgerock.opendj.ldap.ConnectionEventListener;
import org.forgerock.opendj.ldap.ConnectionException;
import org.forgerock.opendj.ldap.ConnectionFactory;
import org.forgerock.opendj.ldap.Connections;
import org.forgerock.opendj.ldap.DN;
@@ -129,8 +130,9 @@
                try {
                    future.get(TEST_TIMEOUT, TimeUnit.SECONDS);
                    fail("The connect request succeeded unexpectedly");
                } catch (TimeoutResultException e) {
                    verifyResultCodeIsClientSideTimeout(e);
                } catch (ConnectionException e) {
                    assertThat(e.getResult().getResultCode()).isEqualTo(
                            ResultCode.CLIENT_SIDE_CONNECT_ERROR);
                    verify(handler).handleErrorResult(same(e));
                }
            }