#fixed code
                                @Override
    public StringRecord processRecord(final Record<P> record) throws Exception {
        StringWriter stringWriter = new StringWriter();
        CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
        Iterable<Object> iterable = fieldExtractor.extractFields(record.getPayload());
        csvPrinter.printRecord(iterable);
        csvPrinter.flush();
        csvPrinter.close();
        return new StringRecord(record.getHeader(), stringWriter.toString());
    }
#vulnerable code 
                                @Override
    public StringRecord processRecord(final Record<P> record) throws Exception {
        StringWriter stringWriter = new StringWriter();
        CSVPrinter csvPrinter = new CSVPrinter(stringWriter, csvFormat);
        Iterable<Object> iterable = fieldExtractor.extractFields(record.getPayload());
        csvPrinter.printRecord(iterable);
        csvPrinter.flush();
        return new StringRecord(record.getHeader(), stringWriter.toString());
    } 
                            #location 7 
                            #vulnerability type RESOURCE_LEAK