From 632803028dfe8bf67c23ece38f647c78c103cf9f Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 20 Sep 2013 22:27:44 +0000
Subject: [PATCH] Fix OPENDJ-1121: Closing a connection after closing the connectionfactory causes NPE
---
opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java
index 4ad9e45..bc49974 100644
--- a/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java
+++ b/opendj3/opendj-ldap-sdk/src/test/java/org/forgerock/opendj/ldap/ConnectionFactoryTestCase.java
@@ -27,8 +27,11 @@
package org.forgerock.opendj.ldap;
+import static java.util.Arrays.asList;
import static org.fest.assertions.Assertions.assertThat;
import static org.forgerock.opendj.ldap.Connections.newFixedConnectionPool;
+import static org.forgerock.opendj.ldap.Connections.newHeartBeatConnectionFactory;
+import static org.forgerock.opendj.ldap.Connections.newLoadBalancer;
import static org.forgerock.opendj.ldap.ErrorResultException.newErrorResult;
import static org.forgerock.opendj.ldap.TestCaseUtils.findFreeSocketAddress;
import static org.forgerock.opendj.ldap.TestCaseUtils.getServerSocketAddress;
@@ -651,15 +654,18 @@
}
}
- @Test(description = "Test for OPENDJ-1121", enabled = false)
+ @Test(description = "Test for OPENDJ-1121: Closing a connection after "
+ + "closing the connection factory causes NPE")
public void testFactoryCloseBeforeConnectionClose() throws Exception {
final ConnectionFactory factory =
- newFixedConnectionPool(new LDAPConnectionFactory(getServerSocketAddress()), 2);
+ newLoadBalancer(new FailoverLoadBalancingAlgorithm(asList(newFixedConnectionPool(
+ newHeartBeatConnectionFactory(new LDAPConnectionFactory(
+ getServerSocketAddress())), 2))));
Connection conn = null;
try {
conn = factory.getConnection();
- factory.close();
} finally {
+ factory.close();
if (conn != null) {
conn.close();
}
--
Gitblit v1.10.0