Uploaded image for project: 'Commons CSV'
  1. Commons CSV
  2. CSV-246

Misplaced null test

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Trivial
    • Resolution: Unresolved
    • 1.7
    • None
    • Parser
    • None

    Description

      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

      Attachments

        Activity

          People

            Unassigned Unassigned
            mdernst Michael Ernst
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: