Buggy code:
public class RegexFunction extends AbstractFunction implements Serializable { private static transient Logger log = LoggingManager . getLoggerForClass ( ) ; public static final String ALL = "ALL" ; public static final String RAND = "RAND" ; public static final String KEY = "__regexFunction" ; private Object [ ] values ; private static Random rand = new Random ( ) ; private static final List desc = new LinkedList ( ) ; private static PatternCacheLRU patternCache = new PatternCacheLRU ( 1000 , new Perl5Compiler ( ) ) ; private transient Pattern templatePattern ; private static ThreadLocal localMatcher = new ThreadLocal ( ) { protected Object initialValue ( ) { } } ; private static final int MIN_PARAMETER_COUNT = 2 ; private static final int MAX_PARAMETER_COUNT = 6 ; public RegexFunction ( ) { } private Object readResolve ( ) throws ObjectStreamException { } public synchronized String execute ( SampleResult previousResult , Sampler currentSampler ) throws InvalidVariableException { String valueIndex = "" ; String defaultValue = "" ; String between = "" ; String name = "" ; Pattern searchPattern ; Object [ ] tmplt ; try { searchPattern = RegexFunction . patternCache . getPattern ( ( ( org . apache . jmeter . engine . util . CompoundVariable ) ( values [ 0 ] ) ) . execute ( ) , READ_ONLY_MASK ) ; tmplt = generateTemplate ( ( ( org . apache . jmeter . engine . util . CompoundVariable ) ( values [ 1 ] ) ) . execute ( ) ) ; if ( ( values . length ) > 2 ) { valueIndex = ( ( org . apache . jmeter . engine . util . CompoundVariable ) ( values [ 2 ] ) ) . execute ( ) ; } if ( valueIndex . equals ( "" ) ) { valueIndex = "1" ; } if ( ( values . length ) > 3 ) { between = ( ( org . apache . jmeter . engine . util . CompoundVariable ) ( values [ 3 ] ) ) . execute ( ) ; } if ( ( values . length ) > 4 ) { String dv = ( ( org . apache . jmeter . engine . util . CompoundVariable ) ( values [ 4 ] ) ) . execute ( ) ; if ( ! ( dv . equals ( "" ) ) ) { defaultValue = dv ; } } if ( ( values . length ) > 5 ) { name = ( ( org . apache . jmeter . engine . util . CompoundVariable ) ( values [ ( ( values . length ) - 1 ) ] ) ) . execute ( ) ; } } catch ( Exception e ) { throw new InvalidVariableException ( e . toString ( ) ) ; } JMeterVariables vars = getVariables ( ) ; vars . put ( name , defaultValue ) ; <START_BUG> if ( ( previousResult == null ) || ( ( previousResult . getResponseData ( ) ) == null ) ) { <END_BUG> return defaultValue ; } List collectAllMatches = new ArrayList ( ) ; try { PatternMatcher matcher = ( ( PatternMatcher ) ( RegexFunction . localMatcher . get ( ) ) ) ; String responseText = new String ( previousResult . getResponseData ( ) , previousResult . getDataEncoding ( ) ) ; PatternMatcherInput input = new PatternMatcherInput ( responseText ) ; while ( matcher . contains ( input , searchPattern ) ) { MatchResult match = matcher . getMatch ( ) ; collectAllMatches . add ( match ) ; } } catch ( NumberFormatException e ) { RegexFunction . log . error ( "" , e ) ; return defaultValue ; } catch ( UnsupportedEncodingException e ) { RegexFunction . log . error ( "Can't<seq2seq4repair_space>convert<seq2seq4repair_space>ResponseData" , e ) ; return defaultValue ; } finally { vars . put ( ( name + "_matchNr" ) , ( "" + ( collectAllMatches . size ( ) ) ) ) ; } if ( ( collectAllMatches . size ( ) ) == 0 ) { return defaultValue ; } if ( valueIndex . equals ( RegexFunction . ALL ) ) { StringBuffer value = new StringBuffer ( ) ; Iterator it = collectAllMatches . iterator ( ) ; boolean first = true ; while ( it . hasNext ( ) ) { if ( ! first ) { value . append ( between ) ; } else { first = false ; } value . append ( generateResult ( ( ( MatchResult ) ( it . next ( ) ) ) , name , tmplt , vars ) ) ; } return value . toString ( ) ; } else if ( valueIndex . equals ( RegexFunction . RAND ) ) { MatchResult result = ( ( MatchResult ) ( collectAllMatches . get ( RegexFunction . rand . nextInt ( collectAllMatches . size ( ) ) ) ) ) ; return generateResult ( result , name , tmplt , vars ) ; } else { try { int index = ( Integer . parseInt ( valueIndex ) ) - 1 ; MatchResult result = ( ( MatchResult ) ( collectAllMatches . get ( index ) ) ) ; return generateResult ( result , name , tmplt , vars ) ; } catch ( NumberFormatException e ) { float ratio = Float . parseFloat ( valueIndex ) ; MatchResult result = ( ( MatchResult ) ( collectAllMatches . get ( ( ( ( int ) ( ( ( collectAllMatches . size ( ) ) * ratio ) + 0.5 ) ) - 1 ) ) ) ) ; return generateResult ( result , name , tmplt , vars ) ; } catch ( IndexOutOfBoundsException e ) { return defaultValue ; } } } private void saveGroups ( MatchResult result , String namep , JMeterVariables vars ) { } public List getArgumentDesc ( ) { }

Fix:
if ( ( previousResult == null ) || ( ( previousResult . getResponseData ( ) . length ) == 0 ) ) {