[
https://issues.apache.org/jira/browse/CSV-246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17057681#comment-17057681
]
Chen commented on CSV-246:
--------------------------
The input files of CSVFileParserTest comes from
commons-csv\src\test\resources\CSVFileParser . All the CSV files that need
CheckComments has comments, so record.getComment() will never return null in
these testcases.
> Misplaced null test
> -------------------
>
> Key: CSV-246
> URL: https://issues.apache.org/jira/browse/CSV-246
> Project: Commons CSV
> Issue Type: Bug
> Components: Parser
> Affects Versions: 1.7
> Reporter: Michael Ernst
> Priority: Trivial
>
> This code appears twice in CSVFileParserTest:
> final String comment = record.getComment().replace("\n", "\\n");
> if (comment != null) {
> The test never fails and seems misplaced.
> If execution gets past replace without a null pointer exception, then the
> variable `comment` is definitely non-null.
> The test should occur before the call to replace, or perhaps is not needed.
> (If it's not needed, why not? The documentation of getComment() says it is
> allowed to return null.)
> Here are the two occurrences:
> https://github.com/apache/commons-csv/blob/master/src/test/java/org/apache/commons/csv/CSVFileParserTest.java#L122
> https://github.com/apache/commons-csv/blob/master/src/test/java/org/apache/commons/csv/CSVFileParserTest.java#L166
--
This message was sent by Atlassian Jira
(v8.3.4#803005)