[
https://issues.apache.org/jira/browse/CSV-246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16872397#comment-16872397
]
Michael Ernst commented on CSV-246:
-----------------------------------
I can do so, but I would first need someone to answer the question in the issue
about the contract of getComment() and why it never fails here. More
generally, better documentation of nullness properties would make the code
clearer and would make the fix obvious. I don't want to guess at that without
guidance from people who know the code.
Thanks!
> 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
(v7.6.3#76005)