Skip to content

Commit 2a0756c

Browse files
committed
Fixed variable name declaration
1 parent 2371c67 commit 2a0756c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/main/java/com/di/jmeter/config/ExtendedCsvDataSet.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ public void iterationStart(LoopIterationEvent iterEvent) {
7070
String[] lineValues = {};
7171
if (variables == null) {
7272
ExtFileServer.setReadPos(0);
73-
initVars(fServer, context, delimiter);
73+
try {
74+
initVars(fServer, context, delimiter);
75+
} catch (IOException e) {
76+
e.printStackTrace();
77+
}
7478
}
7579

7680
JMeterVariables jMeterVariables = context.getVariables();
@@ -148,15 +152,10 @@ public void iterationStart(LoopIterationEvent iterEvent) {
148152
}
149153
}
150154

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) {
152156
int blockSizeInt;
153157
String threadName = context.getThread().getThreadName();
154158

155-
if(fServer.getListSize() < 1){
156-
fServer.reserveFile(filename, getFileEncoding(), alias, ignoreFirstLine);
157-
fServer.loadCsv(filename, ignoreFirstLine);
158-
}
159-
160159
if(autoAllocate){
161160
blockSizeInt = ExtFileServer.getListSize() / JMeterContextService.getTotalThreads();
162161
}else{
@@ -176,7 +175,7 @@ private void initBlockFeatures(String filename, JMeterContext context, ExtFileSe
176175
}
177176
}
178177

179-
private void initVars(ExtFileServer server, final JMeterContext context, String delim) {
178+
private void initVars(ExtFileServer server, final JMeterContext context, String delim) throws IOException {
180179
String fileName = getFilename().trim();
181180
final String names = getVariableNames();
182181
setAlias(context, fileName);
@@ -189,20 +188,22 @@ private void initVars(ExtFileServer server, final JMeterContext context, String
189188
try {
190189
variables = CSVSaveService.csvSplitString(header, delim.charAt(0));
191190
firstLineIsNames = true;ignoreFirstLine = true;
191+
trimVarNames(variables);
192192
} catch (IOException e) {
193193
throw new IllegalArgumentException("Could not split CSV header line from file:" + fileName, e);
194194
}
195-
} else {
195+
}
196+
197+
if(getSelectRow().equalsIgnoreCase("selectRow.sequential")){
196198
server.reserveFile(fileName, getFileEncoding(), alias, ignoreFirstLine);
197199
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);
206207
}
207208
}
208209

@@ -255,7 +256,6 @@ public String getVariableNames() {
255256
}
256257

257258
public void setVariableNames(String variableNames) {
258-
// this.variableNames = variableNames;
259259
if(!ignoreFirstLine){
260260
this.variableNames = variableNames;
261261
}

0 commit comments

Comments
 (0)