Buggy code:
public class LdapGroupSearcherFactory { private static final int searchTimeLimit = 10000 ; static LdapSearcher < LdapEntry [ ] , LdapEntry > createForGroupToPrincipal ( final String baseDn , final String groupDnAttribute , final String groupNameAttribute , final String principalAttribute , final boolean recursive , final GroupName searchBy ) { } static LdapSearcher < LdapEntry [ ] , LdapEntry > createForPrincipalToGroup ( final String groupAttribute , final String groupNameAttribute ) { } private static SearchControls createSearchControl ( final boolean recursive , final String [ ] attributes ) { } private static String [ ] createArray ( final String ... elements ) { } private static class GroupToPrincipalSearcher implements LdapSearcher < LdapEntry [ ] , LdapEntry > { private final String baseDn ; private final String groupDnAttribute ; private final String groupNameAttribute ; private final String [ ] attributeArray ; private final String filterString ; private final boolean recursive ; private final GroupName searchBy ; private GroupToPrincipalSearcher ( final String baseDn , final String groupDnAttribute , final String groupNameAttribute , final String principalAttribute , final boolean recursive , final GroupName searchBy ) { } @ Override public LdapEntry [ ] search ( DirContext dirContext , LdapEntry entry ) throws IOException , NamingException { SearchControls searchControls = LdapGroupSearcherFactory . createSearchControl ( recursive , attributeArray ) ; Set < LdapEntry > foundEntries = new HashSet < LdapEntry > ( ) ; Object [ ] searchParameter = getSearchParameter ( entry ) ; boolean trace = DomainManagementLogger . SECURITY_LOGGER . isTraceEnabled ( ) ; if ( trace ) { DomainManagementLogger . SECURITY_LOGGER . tracef ( "Performing<seq2seq4repair_space>search<seq2seq4repair_space>baseDn=%s,<seq2seq4repair_space>filterString=%s,<seq2seq4repair_space>searchParameter=%s" , baseDn , filterString , Arrays . toString ( searchParameter ) ) ; } NamingEnumeration < SearchResult > searchResults = dirContext . search ( baseDn , filterString , searchParameter , searchControls ) ; if ( trace && ( ( searchResults . hasMore ( ) ) == false ) ) { DomainManagementLogger . SECURITY_LOGGER . trace ( "No<seq2seq4repair_space>search<seq2seq4repair_space>results<seq2seq4repair_space>found." ) ; } while ( searchResults . hasMore ( ) ) { SearchResult current = searchResults . next ( ) ; Attributes attributes = current . getAttributes ( ) ; if ( attributes != null ) { LdapEntry newEntry = convertToLdapEntry ( current , attributes ) ; DomainManagementLogger . SECURITY_LOGGER . tracef ( "Adding<seq2seq4repair_space>%s" , newEntry ) ; foundEntries . add ( newEntry ) ; } else { DomainManagementLogger . SECURITY_LOGGER . tracef ( "No<seq2seq4repair_space>attributes<seq2seq4repair_space>found<seq2seq4repair_space>for<seq2seq4repair_space>%s" , current ) ; } } return foundEntries . toArray ( new LdapEntry [ foundEntries . size ( ) ] ) ; } private LdapEntry convertToLdapEntry ( SearchResult searchResult , Attributes attributes ) throws NamingException { } private Object [ ] getSearchParameter ( final LdapEntry entry ) { } } private static class PrincipalToGroupSearcher implements LdapSearcher < LdapEntry [ ] , LdapEntry > { private final String groupAttribute ; private final String groupNameAttribute ; private PrincipalToGroupSearcher ( final String groupAttribute , final String groupNameAttribute ) { } @ Override public LdapEntry [ ] search ( DirContext dirContext , LdapEntry entry ) throws IOException , NamingException { Set < LdapEntry > foundEntries = new HashSet < LdapEntry > ( ) ; Attributes groups = dirContext . getAttributes ( entry . getDistinguishedName ( ) , new String [ ] { groupAttribute } ) ; Attribute groupRef = groups . get ( groupAttribute ) ; if ( ( groupRef != null ) && ( ( groupRef . size ( ) ) > 0 ) ) { NamingEnumeration < String > groupRefValues = ( ( NamingEnumeration < String > ) ( groupRef . getAll ( ) ) ) ; while ( groupRefValues . hasMore ( ) ) { <START_BUG> String distingushedName = groupRefValues . next ( ) ; <END_BUG> DomainManagementLogger . SECURITY_LOGGER . tracef ( "Group<seq2seq4repair_space>found<seq2seq4repair_space>with<seq2seq4repair_space>distinguishedName=%s" , distingushedName ) ; String simpleName = null ; if ( ( groupNameAttribute ) != null ) { Attributes groupNameAttrs = dirContext . getAttributes ( distingushedName , new String [ ] { groupNameAttribute } ) ; Attribute groupNameAttr = groupNameAttrs . get ( groupNameAttribute ) ; simpleName = ( ( String ) ( groupNameAttr . get ( ) ) ) ; DomainManagementLogger . SECURITY_LOGGER . tracef ( "simpleName<seq2seq4repair_space>%s<seq2seq4repair_space>loaded<seq2seq4repair_space>for<seq2seq4repair_space>group<seq2seq4repair_space>with<seq2seq4repair_space>distinguishedName=%s" , simpleName , distingushedName ) ; } else { DomainManagementLogger . SECURITY_LOGGER . trace ( "No<seq2seq4repair_space>groupNameAttribute<seq2seq4repair_space>to<seq2seq4repair_space>load<seq2seq4repair_space>simpleName" ) ; } foundEntries . add ( new LdapEntry ( simpleName , distingushedName ) ) ; } } else { DomainManagementLogger . SECURITY_LOGGER . tracef ( "No<seq2seq4repair_space>groups<seq2seq4repair_space>found<seq2seq4repair_space>for<seq2seq4repair_space>%s" , entry ) ; } return foundEntries . toArray ( new LdapEntry [ foundEntries . size ( ) ] ) ; } } }

Fix:
String distingushedName = groupRefValues . next ( ) . replace ( "\\" , "\\\\" ) . replace ( "//" , "\\//" ) ;