Skip to content

Commit 6e00f20

Browse files
committed
keep the caching of "record.getComment()"
1 parent 9bc2d80 commit 6e00f20

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/test/java/org/apache/commons/csv/CSVFileParserTest.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ public void testCSVFile(final File testFile) throws Exception {
9393
try (final CSVParser parser = CSVParser.parse(new File(BASE, split[0]), Charset.defaultCharset(), format)) {
9494
for (final CSVRecord record : parser) {
9595
String parsed = Arrays.toString(record.values());
96-
if (checkComments && record.getComment() != null) {
97-
parsed += "#" + record.getComment().replace("\n", "\\n");
96+
String comment = record.getComment();
97+
if (checkComments && comment != null) {
98+
parsed += "#" + comment.replace("\n", "\\n");
9899
}
99100
final int count = record.size();
100101
assertEquals(readTestData(testData), count + ":" + parsed, testFile.getName());
@@ -137,8 +138,9 @@ public void testCSVUrl(final File testFile) throws Exception {
137138
try (final CSVParser parser = CSVParser.parse(resource, Charset.forName("UTF-8"), format)) {
138139
for (final CSVRecord record : parser) {
139140
String parsed = Arrays.toString(record.values());
140-
if (checkComments && record.getComment() != null) {
141-
parsed += "#" + record.getComment().replace("\n", "\\n");
141+
String comment = record.getComment();
142+
if (checkComments && comment != null) {
143+
parsed += "#" + comment.replace("\n", "\\n");
142144
}
143145
final int count = record.size();
144146
assertEquals(readTestData(testData), count + ":" + parsed, testFile.getName());

0 commit comments

Comments
 (0)