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

CSVParser hangs (goes into infinite loop) on getLine() if it's a "comment" line that doesn't contain a delimiter

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Cannot Reproduce
    • None
    • 1.0
    • Parser
    • None

    Description

      if you call CSVParser.getLine() or nextToken() with a line that is a comment as defined by the CSVStrategy but it doesn't contain the delimiter character, the call hangs in an infinite loop

      This code will hang:

              parser = new CSVParser(new StringReader("# abc\n"), new CSVStrategy('\t', '\'', '#'));
              tokens = parser.getLine();
      

      However, if you insert a delimiter char into the incoming string, it'll come through and return an empty string as a result:

              CSVParser parser = new CSVParser(new StringReader("#\tabc"), new CSVStrategy('\t', '\'', '#'));
              String[] tokens = parser.getLine();
              System.out.println("result: "+Arrays.toString(tokens));
      

      It gets stuck in an infinite loop in CSVParser.nextToken() in the loop around line 347

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              toli Toli Kuznets
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: