NihalJain commented on code in PR #2399:
URL: https://github.com/apache/phoenix/pull/2399#discussion_r3246602413
##########
phoenix-core-server/src/main/java/org/apache/phoenix/mapreduce/CsvToKeyValueMapper.java:
##########
@@ -89,17 +90,21 @@ static class CsvLineParser implements LineParser<CSVRecord>
{
private final CSVFormat csvFormat;
CsvLineParser(Character fieldDelimiter, Character quote, Character escape)
{
- this.csvFormat =
CSVFormat.DEFAULT.withIgnoreEmptyLines(true).withDelimiter(fieldDelimiter)
- .withEscape(escape).withQuote(quote);
+ this.csvFormat = CSVFormat.DEFAULT.builder().setIgnoreEmptyLines(true)
+ .setDelimiter(fieldDelimiter).setEscape(escape).setQuote(quote).get();
}
@Override
public CSVRecord parse(String input) throws IOException {
// TODO Creating a new parser for each line seems terribly inefficient
but
// there's no public way to parse single lines via commons-csv. We
should update
// it to create a LineParser class like this one.
- CSVParser csvParser = new CSVParser(new StringReader(input), csvFormat);
- return Iterables.getFirst(csvParser, null);
+ try (CSVParser csvParser =
+ CSVParser.builder().setFormat(csvFormat).setReader(new
StringReader(input)).get()) {
+ return Iterables.getFirst(csvParser, null);
+ } catch (UncheckedIOException e) {
Review Comment:
Please ensure that the newer csvParser actually throws UncheckedIOException
for a bad record. We should not catch anything more unless needed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]