Skip to content

Commit f0391ea

Browse files
committed
formatting changes
1 parent b4abb01 commit f0391ea

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

src/main/java/org/apache/commons/csv/CSVParser.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,11 +464,11 @@ public CSVParser(final Reader reader, final CSVFormat format, final long charact
464464
* </pre>
465465
* @return parsed CSV content of current reading line
466466
*/
467-
private String getLastParsedContent(){
467+
private String getLastParsedContent() {
468468
String parsedContent = "";
469469
int recordListSize = this.recordList.size();
470-
if(recordListSize > 0) {
471-
if(recordListSize <= this.maxParsedTokenCount) {
470+
if (recordListSize > 0) {
471+
if (recordListSize <= this.maxParsedTokenCount) {
472472
parsedContent = String.join("", this.recordList.toArray(Constants.EMPTY_STRING_ARRAY));
473473
} else {
474474
// number of parsed token exceed required token count. Take the expected tokens from the end.
@@ -808,9 +808,9 @@ CSVRecord nextRecord() throws IOException {
808808
do {
809809
this.reusableToken.reset();
810810
// https://issues.apache.org/jira/browse/CSV-147
811-
try{
811+
try {
812812
this.lexer.nextToken(this.reusableToken);
813-
} catch (IOException ioe){
813+
} catch (IOException ioe) {
814814
String errorMessage = "An error occurred while tying to parse the CSV content. Error in line: "
815815
+ this.lexer.getCurrentLineNumber() + ", position: " + this.lexer.getCharacterPosition()
816816
+ ", last parsed content: " + this.getLastParsedContent();

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,6 @@ private void validateRecordPosition(final String lineSeparator) throws IOExcepti
16441644

16451645
@Test
16461646
public void testFaultyCSVShouldThrowErrorWithDetailedMessage() {
1647-
16481647
String csvContent = "col1,col2,col3,col4,col5,col6,col7,col8,col9,col10\n" +
16491648
"rec1,rec2,rec3,rec4,rec5,rec6,rec7,rec8,\"\"rec9\"\",rec10";
16501649

@@ -1654,18 +1653,20 @@ public void testFaultyCSVShouldThrowErrorWithDetailedMessage() {
16541653
.setSkipHeaderRecord(true)
16551654
.build();
16561655

1657-
Exception exception = assertThrows(UncheckedIOException.class, ()-> {
1656+
Exception exception = assertThrows(UncheckedIOException.class, () -> {
16581657
Iterable<CSVRecord> records = csvFormat.parse(stringReader);
16591658
for (CSVRecord record : records) {
1660-
System.out.println(record.get(0) + " " + record.get(1) + " " + record.get(2) + " " + record.get(3) + " " + record.get(4) + " " + record.get(5) + " " + record.get(6) + " " + record.get(7) + " " + record.get(8) + " " + record.get(9));
1659+
System.out.println(record.get(0) + " " + record.get(1) + " " + record.get(2) + " " + record.get(3)
1660+
+ " " + record.get(4) + " " + record.get(5) + " " + record.get(6) + " " + record.get(7)
1661+
+ " " + record.get(8) + " " + record.get(9));
16611662
}
16621663
});
1663-
String expectedErrorMessage = "IOException reading next record: java.io.IOException: An error occurred while tying to parse the CSV content. Error in line: 2, position: 94, last parsed content: ...rec4,rec5,rec6,rec7,rec8";
1664+
String expectedErrorMessage = "IOException reading next record: java.io.IOException: An error occurred while " +
1665+
"tying to parse the CSV content. Error in line: 2, position: 94, last parsed content: " +
1666+
"...rec4,rec5,rec6,rec7,rec8";
16641667
String actualMessage = exception.getMessage();
16651668

16661669
assertTrue(actualMessage.contains(expectedErrorMessage));
1667-
1668-
16691670
}
16701671

16711672
}

0 commit comments

Comments
 (0)