Buggy code:
private static final String SEMI_COLON = ";" ; private static final Hashtable < String , LdapExtClient > ldapConnections = new Hashtable < String , LdapExtClient > ( ) ; private static final Hashtable < String , DirContext > ldapContexts = new Hashtable < String , DirContext > ( ) ; private static final int MAX_SORTED_RESULTS = JMeterUtils . getPropDefault ( "ldapsampler.max_sorted_results" , 1000 ) ; public LDAPExtSampler ( ) { } public void setConnTimeOut ( String connto ) { } public String getConnTimeOut ( ) { } public void setSecure ( String sec ) { } public boolean isSecure ( ) { } public boolean isParseFlag ( ) { } public void setParseFlag ( String parseFlag ) { } public String getUserDN ( ) { } public void setUserDN ( String newUserDN ) { } public String getUserPw ( ) { } public void setUserPw ( String newUserPw ) { } public void setServername ( String servername ) { } public void setPort ( String port ) { } public String getServername ( ) { } public String getPort ( ) { } public void setRootdn ( String newRootdn ) { } public String getRootdn ( ) { } public String getScope ( ) { } public int getScopeAsInt ( ) { } public void setScope ( String newScope ) { } public String getCountlim ( ) { } public long getCountlimAsLong ( ) { } public void setCountlim ( String newClim ) { } public String getTimelim ( ) { } public int getTimelimAsInt ( ) { } public void setTimelim ( String newTlim ) { } public boolean isRetobj ( ) { } public void setRetobj ( String newRobj ) { } public boolean isDeref ( ) { } public void setDeref ( String newDref ) { } public void setTest ( String newTest ) { } public String getTest ( ) { } public void setAttrs ( String newAttrs ) { } public String getAttrs ( ) { } public void setBaseEntryDN ( String newbaseentry ) { } public String getBaseEntryDN ( ) { } public void setArguments ( Arguments value ) { } public Arguments getArguments ( ) { } public void setLDAPArguments ( LDAPArguments value ) { } public LDAPArguments getLDAPArguments ( ) { } private Attributes getUserAttributes ( ) { } private ModificationItem [ ] getUserModAttributes ( ) { } private String [ ] getRequestAttributes ( String reqAttr ) { } private BasicAttribute getBasicAttribute ( String name , String value ) { } public String getLabel ( ) { } private void addTest ( LdapExtClient ldap , DirContext dirContext , SampleResult res ) throws NamingException { } private void deleteTest ( LdapExtClient ldap , DirContext dirContext , SampleResult res ) throws NamingException { } private void modifyTest ( LdapExtClient ldap , DirContext dirContext , SampleResult res ) throws NamingException { } private void bindOp ( LdapExtClient ldap , DirContext dirContext , SampleResult res ) throws NamingException { } private void singleBindOp ( SampleResult res ) throws NamingException { } private void renameTest ( LdapExtClient ldap , DirContext dirContext , SampleResult res ) throws NamingException { } private void unbindOp ( LdapExtClient ldap , DirContext dirContext , SampleResult res ) { } public SampleResult sample ( Entry e ) { } private void writeSearchResults ( final XMLBuffer xmlb , final NamingEnumeration < SearchResult > srch ) throws NamingException { } private void writeSearchResult ( final SearchResult sr , final XMLBuffer xmlb ) throws NamingException { final Attributes attrs = sr . getAttributes ( ) ; final int size = attrs . size ( ) ; final ArrayList < Attribute > sortedAttrs = new ArrayList < Attribute > ( size ) ; xmlb . openTag ( "searchresult" ) ; xmlb . tag ( "dn" , sr . getName ( ) ) ; xmlb . tag ( "returnedattr" , Integer . toString ( size ) ) ; xmlb . openTag ( "attributes" ) ; try { for ( NamingEnumeration < ? extends Attribute > en = attrs . getAll ( ) ; en . hasMore ( ) ; ) { final Attribute attr = en . next ( ) ; sortedAttrs . add ( attr ) ; } sortAttributes ( sortedAttrs ) ; for ( Iterator < Attribute > ait = sortedAttrs . iterator ( ) ; ait . hasNext ( ) ; ) { final Attribute attr = ait . next ( ) ; <START_BUG> StringBuffer sb = new StringBuffer ( ) ; <END_BUG> if ( ( attr . size ( ) ) == 1 ) { sb . append ( getWriteValue ( attr . get ( ) ) ) ; } else { final ArrayList < String > sortedVals = new ArrayList < String > ( attr . size ( ) ) ; boolean first = true ; for ( NamingEnumeration < ? > ven = attr . getAll ( ) ; ven . hasMore ( ) ; ) { final Object value = getWriteValue ( ven . next ( ) ) ; sortedVals . add ( value . toString ( ) ) ; } Collections . sort ( sortedVals ) ; for ( Iterator < String > vit = sortedVals . iterator ( ) ; vit . hasNext ( ) ; ) { final String value = vit . next ( ) ; if ( first ) { first = false ; } else { sb . append ( ",<seq2seq4repair_space>" ) ; } sb . append ( value ) ; } } xmlb . tag ( attr . getID ( ) , sb ) ; } } finally { xmlb . closeTag ( "attributes" ) ; xmlb . closeTag ( "searchresult" ) ; } } private void sortAttributes ( final ArrayList < Attribute > sortedAttrs ) { } private void sortResults ( final ArrayList < SearchResult > sortedResults ) { } private String normaliseSearchDN ( final SearchResult sr , final String searchBase , final String rootDn ) { } private String getWriteValue ( final Object value ) { }

Fix:
StringBuilder sb = new StringBuilder ( ) ;