Skip to content

Commit 2d6f379

Browse files
authored
Merge pull request #17 from rollno748/csv-config-2.1
Added handling for empty line - Issue-16
2 parents d8175dd + 8e78872 commit 2d6f379

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.di.jmeter.ecsv</groupId>
66
<artifactId>di-extended-csv</artifactId>
7-
<version>2.0</version>
7+
<version>2.1</version>
88
<!--Properties-->
99
<properties>
1010
<jmeter-version>5.1.1</jmeter-version>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ public void iterationStart(LoopIterationEvent iterationEvent) {
105105
for (int a = 0; a < variables.length && a < lineValues.length; a++) {
106106
jMeterVariables.put(variables[a], lineValues[a]);
107107
}
108+
}else {
109+
for (String variable : variables) {
110+
jMeterVariables.put(variable, null);
111+
}
108112
}
109113
break;
110114
case "once":
@@ -329,4 +333,4 @@ public void setBlockSize(String blockSize) {
329333
public String printAllProperties() {
330334
return String.format("Filename: %s\n,FileEncoding: %s\n VariableName: %s\n IgnoreFirstLine: %s\n Delimiter: %s\n IsQuotedData: %s\n SelectRow: %s\n UpdateValue: %s\n OOValue: %s\n AutoAllocate: %s\n Allocate: %s\n BlockSize: %s\n",getFilename(),getFileEncoding(),getVariableNames(),isIgnoreFirstLine(),getDelimiter(),isQuotedData(),getSelectRow(),getUpdateValue(),getOoValue(),isAllocate(),isAutoAllocate(),getBlockSize());
331335
}
332-
}
336+
}

src/main/java/com/di/jmeter/config/gui/ExtendedCsvDataSetConfigGui.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private void init() {
282282
try {
283283
File file = new File(filenameField.getText());
284284
Desktop desktop = Desktop.getDesktop();
285-
if(filenameField.getText().equals("") || filenameField.getText().isEmpty()){
285+
if(filenameField.getText().isEmpty() || filenameField.getText().isEmpty()){
286286
throw new FileNotFoundException();
287287
}
288288
if(!file.exists()){

src/main/java/com/di/jmeter/utils/FileServerExtended.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ public class FileServerExtended {
6363

6464
private File base;
6565
private static int rowCount;
66-
private static ThreadLocal<Integer> endPos = new ThreadLocal<>();
67-
private static ThreadLocal<Integer> startPos = new ThreadLocal<>();
68-
private static ThreadLocal<Integer> readPos = new ThreadLocal<>();
66+
private static final ThreadLocal<Integer> endPos = new ThreadLocal<>();
67+
private static final ThreadLocal<Integer> startPos = new ThreadLocal<>();
68+
private static final ThreadLocal<Integer> readPos = new ThreadLocal<>();
6969
private final Map<String, FileEntry> files = new HashMap<>();
7070
private static final FileServerExtended server = new FileServerExtended();
7171

@@ -591,7 +591,8 @@ public void calculateRowCount(String filename, boolean ignoreFirstLine) {
591591
try (BufferedReader br = new BufferedReader(new FileReader(String.valueOf(fileEntry.file.toPath())))) {
592592
count = (int) br.lines().count();
593593
} catch (IOException e) {
594-
e.printStackTrace();
594+
log.error(e.toString());
595+
595596
}
596597
this.setRowCount(ignoreFirstLine ? count-1 : count );
597598
}

0 commit comments

Comments
 (0)