From 8e9e861649292af6d4bd55d228243cf115addc09 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Fri, 23 Sep 2011 19:42:56 +0000
Subject: [PATCH] Fix OPENDJ-292: LDAP PTA NPE when base-dn or bind-dn not exist on secondary server

---
 opends/src/server/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java |   41 ++++++++++++++---------------------------
 1 files changed, 14 insertions(+), 27 deletions(-)

diff --git a/opends/src/server/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java b/opends/src/server/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
index 270f87c..6968ca3 100644
--- a/opends/src/server/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
+++ b/opends/src/server/org/opends/server/extensions/LDAPPassThroughAuthenticationPolicyFactory.java
@@ -101,24 +101,17 @@
       {
         this.startIndex = nextIndex = startIndex;
 
-        DirectoryException lastException = null;
+        DirectoryException lastException;
         do
         {
           factory = factories[nextIndex];
-          if (factory.isAvailable())
+          if (factory.isAvailable)
           {
             try
             {
-              if (factory.isAvailable)
-              {
-                connection = factory.getConnection();
-                incrementNextIndex();
-                return;
-              }
-              else if (lastException == null)
-              {
-                lastException = factory.lastException;
-              }
+              connection = factory.getConnection();
+              incrementNextIndex();
+              return;
             }
             catch (final DirectoryException e)
             {
@@ -130,6 +123,10 @@
               lastException = e;
             }
           }
+          else
+          {
+            lastException = factory.lastException;
+          }
           incrementNextIndex();
         }
         while (nextIndex != startIndex);
@@ -222,16 +219,13 @@
         while (nextIndex != startIndex)
         {
           factory = factories[nextIndex];
-          if (factory.isAvailable())
+          if (factory.isAvailable)
           {
             try
             {
-              if (factory.isAvailable)
-              {
-                connection = factory.getConnection();
-                incrementNextIndex();
-                return;
-              }
+              connection = factory.getConnection();
+              incrementNextIndex();
+              return;
             }
             catch (final DirectoryException de)
             {
@@ -319,13 +313,6 @@
           throw e;
         }
       }
-
-
-
-      private boolean isAvailable()
-      {
-        return isAvailable;
-      }
     }
 
 
@@ -397,7 +384,7 @@
     {
       for (final MonitoredConnectionFactory factory : factories)
       {
-        if (!factory.isAvailable())
+        if (!factory.isAvailable)
         {
           try
           {

--
Gitblit v1.10.0