Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.0
    • Component/s: Parser
    • Labels:
      None

      Description

      If the input file ends with comment lines, the parser runs into an endless loop. The example shows, that the CSV parser runs into an endless loop, if the input is one comment line. '#' is the comment character here:

      import org.apache.commons.csv.CSVStrategy;
      import org.apache.commons.csv.CSVParser;
      import java.io.StringReader;
      import java.io.IOException;
      
      public class TestCSV {
          public static void main(String [] args) throws IOException {
              CSVStrategy strategy=new CSVStrategy(',','"','#','\\',false,false,false,false);
              
              CSVParser parser = new CSVParser(new StringReader("# A, B\n"), strategy);
              
              System.out.println("Go into an endless loop...");
              String []line=parser.getLine();
          }
      }
      

        Issue Links

          Activity

          Hide
          Bjoern Voigt added a comment -

          The patch stops the loop, if End-of-file is detected.

          Show
          Bjoern Voigt added a comment - The patch stops the loop, if End-of-file is detected.
          Hide
          Yonik Seeley added a comment -

          Thanks Bjoern, I also hit this bug with my random testing.
          I've added a test and committed this.

          Show
          Yonik Seeley added a comment - Thanks Bjoern, I also hit this bug with my random testing. I've added a test and committed this.

            People

            • Assignee:
              Unassigned
              Reporter:
              Bjoern Voigt
            • Votes:
              2 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1h
                1h
                Remaining:
                Remaining Estimate - 1h
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified

                  Development