SampleResult previousResult,
Sampler currentSampler)
throws InvalidVariableException
{
JMeterVariables vars = getVariables();
if (values.length >= PARAM_NAME)
{
myName = ((CompoundVariable) values[PARAM_NAME-1]).execute();
}
myValue = ERR_IND;
/*
* To avoid re-opening the file repeatedly after an error,
* only try to open it in the first execute() call
* (It may be re=opened at EOF, but that will cause at most
* one failure.)
*/
if (firstTime) {
openFile();
firstTime=false;
}
if (null != myBread)
{ // Did we open the file?
try
{
String line = myBread.readLine();
if (line == null)
{ // EOF, re-open file
String tn = Thread.currentThread().getName();
log.info(tn+" EOF on file " + fileName);//$NON-NLS-1$
closeFile();
openFile();
if (myBread != null) {
line = myBread.readLine();
} else {
line = ERR_IND;
if (myEnd != COUNT_UNUSED){// Are we processing a file sequence?
log.info(tn + " Detected end of sequence.");
throw new JMeterStopThreadException("End of sequence");
}
}
}
myValue = line;
}
catch (IOException e)
{
String tn = Thread.currentThread().getName();
log.error(tn + " error reading file " + e.toString());//$NON-NLS-1$
}
} else { // File was not opened successfully
if (myEnd != COUNT_UNUSED){// Are we processing a file sequence?
String tn = Thread.currentThread().getName();
log.info(tn + " Detected end of sequence.");
throw new JMeterStopThreadException("End of sequence");
}
}
if (myName.length() > 0){
vars.put(myName, myValue);
}
if (log.isDebugEnabled()){
String tn = Thread.currentThread().getName();
log.debug(tn + " name:" //$NON-NLS-1$