#vulnerable code 
                                @Test
    public void parse() throws IOException {
        final File csvData = new File("src/test/resources/csv-167/sample1.csv");
        final BufferedReader br = new BufferedReader(new FileReader(csvData));
        String s = null;
        int totcomment = 0;
        int totrecs = 0;
        boolean lastWasComment = false;
        while((s=br.readLine()) != null) {
            if (s.startsWith("#")) {
                if (!lastWasComment) { // comments are merged
                    totcomment++;
                }
                lastWasComment = true;
            } else {
                totrecs++;
                lastWasComment = false;
            }
        }
        br.close();
        CSVFormat format = CSVFormat.DEFAULT;
        //
        format = format.withAllowMissingColumnNames(false);
        format = format.withCommentMarker('#');
        format = format.withDelimiter(',');
        format = format.withEscape('\\');
        format = format.withHeader("author", "title", "publishDate");
        format = format.withHeaderComments("headerComment");
        format = format.withNullString("NULL");
        format = format.withIgnoreEmptyLines(true);
        format = format.withIgnoreSurroundingSpaces(true);
        format = format.withQuote('"');
        format = format.withQuoteMode(QuoteMode.ALL);
        format = format.withRecordSeparator('\n');
        format = format.withSkipHeaderRecord(false);
        //
        final CSVParser parser = CSVParser.parse(csvData, Charset.defaultCharset(), format);
        int comments = 0;
        int records = 0;
        for (final CSVRecord csvRecord : parser) {
//            System.out.println(csvRecord.isComment() + "[" + csvRecord.toString() + "]");
            records++;
            if (csvRecord.hasComment()) {
                comments++;
            }
        }
        // Comment lines are concatenated, in this example 4 lines become 2 comments.
        Assert.assertEquals(totcomment, comments);
        Assert.assertEquals(totrecs, records); // records includes the header
    } 
                            #location 13 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                @Test
    public void parse() throws IOException {
        final BufferedReader br = new BufferedReader(getTestInput());
        String s = null;
        int totcomment = 0;
        int totrecs = 0;
        boolean lastWasComment = false;
        while((s=br.readLine()) != null) {
            if (s.startsWith("#")) {
                if (!lastWasComment) { // comments are merged
                    totcomment++;
                }
                lastWasComment = true;
            } else {
                totrecs++;
                lastWasComment = false;
            }
        }
        br.close();
        CSVFormat format = CSVFormat.DEFAULT;
        //
        format = format.withAllowMissingColumnNames(false);
        format = format.withCommentMarker('#');
        format = format.withDelimiter(',');
        format = format.withEscape('\\');
        format = format.withHeader("author", "title", "publishDate");
        format = format.withHeaderComments("headerComment");
        format = format.withNullString("NULL");
        format = format.withIgnoreEmptyLines(true);
        format = format.withIgnoreSurroundingSpaces(true);
        format = format.withQuote('"');
        format = format.withQuoteMode(QuoteMode.ALL);
        format = format.withRecordSeparator('\n');
        format = format.withSkipHeaderRecord(false);
        //
        final CSVParser parser = format.parse(getTestInput());
        int comments = 0;
        int records = 0;
        for (final CSVRecord csvRecord : parser) {
            records++;
            if (csvRecord.hasComment()) {
                comments++;
            }
        }
        // Comment lines are concatenated, in this example 4 lines become 2 comments.
        Assert.assertEquals(totcomment, comments);
        Assert.assertEquals(totrecs, records); // records includes the header
    }