@@ -70,7 +70,11 @@ public void iterationStart(LoopIterationEvent iterEvent) {
70
70
String [] lineValues = {};
71
71
if (variables == null ) {
72
72
ExtFileServer .setReadPos (0 );
73
- initVars (fServer , context , delimiter );
73
+ try {
74
+ initVars (fServer , context , delimiter );
75
+ } catch (IOException e ) {
76
+ e .printStackTrace ();
77
+ }
74
78
}
75
79
76
80
JMeterVariables jMeterVariables = context .getVariables ();
@@ -148,15 +152,10 @@ public void iterationStart(LoopIterationEvent iterEvent) {
148
152
}
149
153
}
150
154
151
- private void initBlockFeatures (String filename , JMeterContext context , ExtFileServer fServer , boolean autoAllocate , String blockSize ) throws IOException {
155
+ private void initBlockFeatures (String filename , JMeterContext context , ExtFileServer fServer , boolean autoAllocate , String blockSize ) {
152
156
int blockSizeInt ;
153
157
String threadName = context .getThread ().getThreadName ();
154
158
155
- if (fServer .getListSize () < 1 ){
156
- fServer .reserveFile (filename , getFileEncoding (), alias , ignoreFirstLine );
157
- fServer .loadCsv (filename , ignoreFirstLine );
158
- }
159
-
160
159
if (autoAllocate ){
161
160
blockSizeInt = ExtFileServer .getListSize () / JMeterContextService .getTotalThreads ();
162
161
}else {
@@ -176,7 +175,7 @@ private void initBlockFeatures(String filename, JMeterContext context, ExtFileSe
176
175
}
177
176
}
178
177
179
- private void initVars (ExtFileServer server , final JMeterContext context , String delim ) {
178
+ private void initVars (ExtFileServer server , final JMeterContext context , String delim ) throws IOException {
180
179
String fileName = getFilename ().trim ();
181
180
final String names = getVariableNames ();
182
181
setAlias (context , fileName );
@@ -189,20 +188,22 @@ private void initVars(ExtFileServer server, final JMeterContext context, String
189
188
try {
190
189
variables = CSVSaveService .csvSplitString (header , delim .charAt (0 ));
191
190
firstLineIsNames = true ;ignoreFirstLine = true ;
191
+ trimVarNames (variables );
192
192
} catch (IOException e ) {
193
193
throw new IllegalArgumentException ("Could not split CSV header line from file:" + fileName , e );
194
194
}
195
- } else {
195
+ }
196
+
197
+ if (getSelectRow ().equalsIgnoreCase ("selectRow.sequential" )){
196
198
server .reserveFile (fileName , getFileEncoding (), alias , ignoreFirstLine );
197
199
variables = JOrphanUtils .split (names , "," );
198
- }
199
- trimVarNames (variables );
200
- if (getSelectRow ().equalsIgnoreCase ("selectRow.unique" )){
201
- try {
202
- initBlockFeatures (alias , context , server , isAutoAllocate (), getBlockSize ());
203
- } catch (IOException e ) {
204
- e .printStackTrace ();
205
- }
200
+ trimVarNames (variables );
201
+ }else if (getSelectRow ().equalsIgnoreCase ("selectRow.unique" ) || getSelectRow ().equalsIgnoreCase ("selectRow.random" )){
202
+ server .reserveFile (filename , getFileEncoding (), alias , ignoreFirstLine );
203
+ server .loadCsv (filename , ignoreFirstLine );
204
+ initBlockFeatures (alias , context , server , isAutoAllocate (), getBlockSize ());
205
+ variables = JOrphanUtils .split (names , "," );
206
+ trimVarNames (variables );
206
207
}
207
208
}
208
209
@@ -255,7 +256,6 @@ public String getVariableNames() {
255
256
}
256
257
257
258
public void setVariableNames (String variableNames ) {
258
- // this.variableNames = variableNames;
259
259
if (!ignoreFirstLine ){
260
260
this .variableNames = variableNames ;
261
261
}
0 commit comments