Buggy code:
private DirContext dirContext , SampleResult res ) throws NamingException { } private void deleteTest ( DirContext dirContext , SampleResult res ) throws NamingException { } private void modifyTest ( DirContext dirContext , SampleResult res ) throws NamingException { } private void bindOp ( DirContext dirContext , SampleResult res ) throws NamingException { } private void singleBindOp ( SampleResult res ) throws NamingException { } private void renameTest ( DirContext dirContext , SampleResult res ) throws NamingException { } private void unbindOp ( DirContext dirContext , SampleResult res ) { } public SampleResult sample ( Entry e ) { XMLBuffer xmlBuffer = new XMLBuffer ( ) ; xmlBuffer . openTag ( "ldapanswer" ) ; SampleResult res = new SampleResult ( ) ; res . setResponseData ( "successfull" , null ) ; res . setResponseMessage ( "Success" ) ; res . setResponseCode ( "0" ) ; res . setContentType ( "text//xml" ) ; boolean isSuccessful = true ; res . setSampleLabel ( getName ( ) ) ; DirContext dirContext = LDAPExtSampler . ldapContexts . get ( getThreadName ( ) ) ; try { xmlBuffer . openTag ( "operation" ) ; final String testType = getTest ( ) ; xmlBuffer . tag ( "opertype" , testType ) ; LDAPExtSampler . log . debug ( ( "performing<seq2seq4repair_space>test:<seq2seq4repair_space>" + testType ) ) ; if ( testType . equals ( LDAPExtSampler . UNBIND ) ) { res . setSamplerData ( "Unbind" ) ; xmlBuffer . tag ( "baseobj" , getRootdn ( ) ) ; xmlBuffer . tag ( "binddn" , getUserDN ( ) ) ; unbindOp ( dirContext , res ) ; } else if ( testType . equals ( LDAPExtSampler . BIND ) ) { res . setSamplerData ( ( "Bind<seq2seq4repair_space>as<seq2seq4repair_space>" + ( getUserDN ( ) ) ) ) ; xmlBuffer . tag ( "baseobj" , getRootdn ( ) ) ; xmlBuffer . tag ( "binddn" , getUserDN ( ) ) ; xmlBuffer . tag ( "connectionTO" , getConnTimeOut ( ) ) ; bindOp ( dirContext , res ) ; } else if ( testType . equals ( LDAPExtSampler . SBIND ) ) { res . setSamplerData ( ( "SingleBind<seq2seq4repair_space>as<seq2seq4repair_space>" + ( getUserDN ( ) ) ) ) ; xmlBuffer . tag ( "baseobj" , getRootdn ( ) ) ; xmlBuffer . tag ( "binddn" , getUserDN ( ) ) ; xmlBuffer . tag ( "connectionTO" , getConnTimeOut ( ) ) ; singleBindOp ( res ) ; } else if ( testType . equals ( LDAPExtSampler . COMPARE ) ) { res . setSamplerData ( ( ( ( "Compare<seq2seq4repair_space>" + ( getPropertyAsString ( LDAPExtSampler . COMPAREFILT ) ) ) + "<seq2seq4repair_space>" ) + ( getPropertyAsString ( LDAPExtSampler . COMPAREDN ) ) ) ) ; xmlBuffer . tag ( "comparedn" , getPropertyAsString ( LDAPExtSampler . COMPAREDN ) ) ; xmlBuffer . tag ( "comparefilter" , getPropertyAsString ( LDAPExtSampler . COMPAREFILT ) ) ; NamingEnumeration < SearchResult > cmp = null ; try { res . sampleStart ( ) ; cmp = LdapExtClient . compare ( dirContext , getPropertyAsString ( LDAPExtSampler . COMPAREFILT ) , getPropertyAsString ( LDAPExtSampler . COMPAREDN ) ) ; if ( ! ( cmp . hasMore ( ) ) ) { res . setResponseCode ( "5" ) ; res . setResponseMessage ( "compareFalse" ) ; isSuccessful = false ; } } finally { res . sampleEnd ( ) ; if ( cmp != null ) { cmp . close ( ) ; } } } else if ( testType . equals ( LDAPExtSampler . ADD ) ) { res . setSamplerData ( ( "Add<seq2seq4repair_space>object<seq2seq4repair_space>" + ( getBaseEntryDN ( ) ) ) ) ; xmlBuffer . tag ( "attributes" , getArguments ( ) . toString ( ) ) ; xmlBuffer . tag ( "dn" , getBaseEntryDN ( ) ) ; addTest ( dirContext , res ) ; } else if ( testType . equals ( LDAPExtSampler . DELETE ) ) { res . setSamplerData ( ( "Delete<seq2seq4repair_space>object<seq2seq4repair_space>" + ( getBaseEntryDN ( ) ) ) ) ; xmlBuffer . tag ( "dn" , getBaseEntryDN ( ) ) ; deleteTest ( dirContext , res ) ; } else if ( testType . equals ( LDAPExtSampler . MODIFY ) ) { res . setSamplerData ( ( "Modify<seq2seq4repair_space>object<seq2seq4repair_space>" + ( getBaseEntryDN ( ) ) ) ) ; xmlBuffer . tag ( "dn" , getBaseEntryDN ( ) ) ; xmlBuffer . tag ( "attributes" , getLDAPArguments ( ) . toString ( ) ) ; modifyTest ( dirContext , res ) ; } else if ( testType . equals ( LDAPExtSampler . RENAME ) ) { res . setSamplerData ( ( ( ( "ModDN<seq2seq4repair_space>object<seq2seq4repair_space>" + ( getPropertyAsString ( LDAPExtSampler . MODDDN ) ) ) + "<seq2seq4repair_space>to<seq2seq4repair_space>" ) + ( getPropertyAsString ( LDAPExtSampler . NEWDN ) ) ) ) ; xmlBuffer . tag ( "dn" , getPropertyAsString ( LDAPExtSampler . MODDDN ) ) ; xmlBuffer . tag ( "newdn" , getPropertyAsString ( LDAPExtSampler . NEWDN ) ) ; renameTest ( dirContext , res ) ; } else if ( testType . equals ( LDAPExtSampler . SEARCH ) ) { final String scopeStr = getScope ( ) ; final int scope = getScopeAsInt ( ) ; final String searchFilter = getPropertyAsString ( LDAPExtSampler . SEARCHFILTER ) ; final String searchBase = getPropertyAsString ( LDAPExtSampler . SEARCHBASE ) ; final String timeLimit = getTimelim ( ) ; final String countLimit = getCountlim ( ) ; res . setSamplerData ( ( "Search<seq2seq4repair_space>with<seq2seq4repair_space>filter<seq2seq4repair_space>" + searchFilter ) ) ; xmlBuffer . tag ( "searchfilter" , searchFilter ) ; xmlBuffer . tag ( "baseobj" , getRootdn ( ) ) ; xmlBuffer . tag ( "searchbase" , searchBase ) ; xmlBuffer . tag ( "scope" , scopeStr ) ; xmlBuffer . tag ( "countlimit" , countLimit ) ; xmlBuffer . tag ( "timelimit" , timeLimit ) ; NamingEnumeration < SearchResult > srch = null ; try { res . sampleStart ( ) ; srch = LdapExtClient . searchTest ( dirContext , searchBase , searchFilter , scope , getCountlimAsLong ( ) , getTimelimAsInt ( ) , getRequestAttributes ( getAttrs ( ) ) , isRetobj ( ) , isDeref ( ) ) ; if ( isParseFlag ( ) ) { try { xmlBuffer . openTag ( "searchresults" ) ; writeSearchResults ( xmlBuffer , srch ) ; } finally { xmlBuffer . closeTag ( "searchresults" ) ; } } else { xmlBuffer . tag ( "searchresults" , ( "hasElements=" + ( srch . hasMoreElements ( ) ) ) ) ; } } finally { if ( srch != null ) { srch . close ( ) ; } res . sampleEnd ( ) ; } } } catch ( NamingException ex ) { String returnData = ex . toString ( ) ; final int indexOfLDAPErrCode = returnData . indexOf ( "LDAP:<seq2seq4repair_space>error<seq2seq4repair_space>code" ) ; if ( indexOfLDAPErrCode >= 0 ) { <START_BUG> res . setResponseMessage ( returnData . substring ( ( indexOfLDAPErrCode + 21 ) , returnData . indexOf ( "]" ) ) ) ; <END_BUG>

Fix:
res . setResponseMessage ( returnData . substring ( ( indexOfLDAPErrCode + 21 ) , returnData . indexOf ( ']' ) ) ) ;