/* * Iterate through the URLs of a referral. If successful then perform * a search operation and merge the received results with the current * results. */ protected final boolean hasMoreReferrals() throws NamingException { if ((refEx != null) && (refEx.hasMoreReferrals() || refEx.hasMoreReferralExceptions())) { if (homeCtx.handleReferrals == LdapClient.LDAP_REF_THROW) { throw (NamingException) (refEx.fillInStackTrace()); } // process the referrals sequentially while (true) { LdapReferralContext refCtx = (LdapReferralContext) refEx.getReferralContext(homeCtx.envprops, homeCtx.reqCtls); try { update(getReferredResults(refCtx)); break; } catch (LdapReferralException re) { // record a previous exception if (errEx == null) { errEx = re.getNamingException(); } refEx = re; continue; } finally { // Make sure we close referral context refCtx.close(); } } return hasMoreImpl(); } else { cleanup(); if (errEx != null) { throw errEx; } return (false); } }