From 915c6a916b0bad1a86cdd470df0131f3dcd1f10e Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Tue, 22 Jul 2014 13:43:36 +0000 Subject: [PATCH] Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud) 75702: Merged DEV to HEAD-BUG-FIX (5.0/Cloud) 75532: ACE-2133 : LDAP logging throws NullPointerException Added additional checks to avoid NPE while closing the contexts. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77540 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../security/sync/ldap/LDAPUserRegistry.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/source/java/org/alfresco/repo/security/sync/ldap/LDAPUserRegistry.java b/source/java/org/alfresco/repo/security/sync/ldap/LDAPUserRegistry.java index 64b122cdc6..2468ef1fb3 100644 --- a/source/java/org/alfresco/repo/security/sync/ldap/LDAPUserRegistry.java +++ b/source/java/org/alfresco/repo/security/sync/ldap/LDAPUserRegistry.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2005-2013 Alfresco Software Limited. + * Copyright (C) 2005-2014 Alfresco Software Limited. * * This file is part of Alfresco * @@ -992,14 +992,21 @@ public class LDAPUserRegistry implements UserRegistry, LDAPNameResolver, Initial String name = result.getNameInNamespace(); // Close the contexts, see ALF-20682 - ((Context)result.getObject()).close(); + Context context = (Context) result.getObject(); + if (context != null) + { + context.close(); + } result = null; - return name; } // Close the contexts, see ALF-20682 - ((Context)result.getObject()).close(); + Context context = (Context) result.getObject(); + if (context != null) + { + context.close(); + } result = null; } @@ -1025,7 +1032,11 @@ public class LDAPUserRegistry implements UserRegistry, LDAPNameResolver, Initial { try { - ((Context)result.getObject()).close(); + Context context = (Context) result.getObject(); + if (context != null) + { + context.close(); + } } catch (Exception e) {