No, it can hang with Java 25 too: just create a bigger CSV. Try to duplicate the lines of my CSV (excluding the first 5 headerlines) to get a CSV of 7000+ lines and zip it again. This means that tests might pass but the application could hang in production when it gets a CSV bigger that the one used in tests. A very nasty scenario. I suspect a deadlock: I have noted that method ZipFile.stream() is internally synchronized in recent Java versions (not in Java 8) and that you are using threads, even...
No, it can hang with Java 25 too: just create a bigger CSV. Try to duplicate the lines of my CSV (excluding the first 5 headerlines) to get a CSV of 7000+ lines and zip it again. This means that tests might pass but the application could hang in production when it get a CSV bigger that the one used in tests. A very nasty scenario. I suspect a deadlock: I have noted that method ZipFile.stream() is internally synchronized in recent Java versions (not in Java 8) and that you are using threads, even...
Jo - I am going to throw you a curve ball that for me lowers the priority of this. I just downloaded Java 25, which is also noted as an LTS version and it works. So: Java 8 - test passes Java 11 - test fails Java 17 - test fails Java 21- test fails Java 25 - test passes
For giggles I did recompile and ran the code in both java 11 and java 21 (other LTS versions of java) and both had the same issue. But it does tell me the issue started with java version > 8 and <= 11 instead of <= 17.
Hello Jo. This is a most interesting issue. Like your own comment stated I was able to port the tests directly into opencsv which I always run in Java 8 by replacing the var in testOKnoStream with List<? extends ZipEntry> and it runs without issue. Which tells me this is not an opencsv issue per se but a change in one of the later versions of java after java 8 that is not backwards compatible. I will try and play with it this weekend some to open up my debugging settings in IntelliJ to be able to...
What's new
Upgrade to commons-text 1.15.0
Done - changes merged in and will be in the next release.
Feature Request #174 - update dependencies (specifically commons-text)
Upgrade to commons-text 1.15.0
Opencsv may hang when reading from zip file
Opencsv may hang when reading from zip file
Quotation for numbers and booleans
CsvBindByName capitalizes headers when writing
Hello Seprfu There are no updates on this as it was fixed a long time ago. If you google or search through the tickets you will see this was brought up in 2020 in Support Request #87 which referenced the Stackoverflow ticket that posted a fix for the issue. And Seprfu while I agree that flexibility is NOT a dirty word there is one thing that trumps flexibility and that is backwards compatibility! Anyone who has worked on a highly used library (opencsv is downloaded millions of times a month last...
Any updates on that? This is a library, whatever reasoning the original developer had, it shouldn't act as a policeman and enforce its own rules. It should be flexible. There are many dirty workarounds for this issue on the internet because this is what users need.
Add column name or index information in CsvException
hi, since https://mvnrepository.com/artifact/org.apache.commons/commons-beanutils2 has been released, can we consider getting rid of commons-collections4?
Sorry Michael for the delay again - work, family, and all the life stuff again as always :) I see your frustration but I do not believe it is hard to differentiate - just confusing because it happened before what you think a read has happened. But the error stated that a mandatory field is missing information. That said what surporised me reading the code is that internally it very specifically reads the first record after reading the header. Unfortunately it was done in a private inner class with...
Sorry Michael for the delay again - work, family, and all the life stuff again as always :) I see your frustration but I do not believe it is hard to differentiate - just confusing because it happened before what you think a read has happened. But the error stated that a mandatory field is missing information. That said what surporised me reading the code is that internally it very specifically reads the first record after reading the header. Unfortunately it was done in a private inner class with...
Of course you are right: the implementation of the iterator() interface is up to the implementor. But the current implementation makes it very hard to differentiate between an error in the header line and an error in the first content line. file1.csv COLUMN_A, COLUMN_B ,b throws java.lang.RuntimeException: com.opencsv.exceptions.CsvRequiredFieldEmptyException: Field 'columnA' is mandatory but no value was provided. file2.csv COLUMN_A, COLUMN_C a, b throws java.lang.RuntimeException: Error capturing...
OpenCsvReader.iterator() parses content line
Sorry for the delay in the response but work happens :) My rejection is based around your last statement. The iterator() call should not read a content line. Only the first iterator.next() call should parse the content line and throw an exeption. Iterator is an interface - how it is implemented is wholly up to whomever implements the class. Which allows for the implementor to add desired features like caching/buffering. Besides what's the best way to implement the hasNext method? Go ahead and read...
OpenCsvReader.iterator() parses content line
Yes, you are of course right, but maybe I haven't been precise enough. What I really wanted to say by hidden is that, my code cannot access that method from outside of the converter itself, but this is the method that gets the actual value that will be set in field. While I can override that method I can never call it by myself and that is problem in my approach to make records work. If you check mapping strategies that I created they are now using reflections to call the convert method in order...
Added tests for Bug261
convert is not hidden - it is an abstract method that is defined by whomever extends the AbstractBeanField. You can see examples of that in BeanFieldSplit, BeanFieldSingleValue, ConvertLanguageToBoolean. That said I can change preProcessValue and validateValue in AbstractBeanField from private to protected if you want to call them directly from the class you are using that extends the AbstractBeanField. Short term you can copy out the two methods and put them in your class. Or if you do not use the...
hi, I checked and it is public, however for some reason dot was added as part of url. This should work fine: https://github.com/Svanar/opencsv-record-strategy
Kamil is your github project private because I am getting a 404 when I try and view it.
Quote read as part of the value when using keepCarriageReturn
Closing this as works for me. This is not a bug because the CsvParser typically reads a field as all the characters to the next comma which is why the carriage return was being added. Enabling strict quotes reads from quote to quote.
Hi Scott, thank you for taking your time to look into my request. I fully understand why you don't want to add support for records due to compatibility reasons. In order to provide more details (and to make sure that my approach would work) I created this simple POC: https://github.com/Svanar/opencsv-record-strategy. Main logic part is in classes RecordColumnPositionMappingStrategy and RecordHeaderColumnNameMappingStrategy. The core functionality being method: private Object extractValue( BeanField<T,...
java record support/value extraction
Hello Kamil Sorry but there is no plans to support Java Records in opencsv. Java Records was added in Java 14 and standardized in Java 16 while we are committed to maintaining compatibility with Java 8. Now for the second part I am very happy to open access (as little as possible - Least Privlege and all that) to allow you to override as neccessary. But I would like a definitive list as to what you want opened and why. The reason I am being picky is your request actually confused me.... okay that...
java record support/value extraction
This goes back to what I pondered earlier that about getting a file from a system where the default newline is \r\n because if I change the string to this it works. @Test void test_whenValueIsMonoLine_andOnlyOneChar_withNewlineOutsideQuotes() throws CsvValidationException, IOException { final String csv = "\"Text with commas, and\r\nnew lines\"\n" + "\"Text with commas, and\r\nnew lines\""; final CSVReader reader = new CSVReaderBuilder(new StringReader((csv))) .withKeepCarriageReturn(true) .build();...
Hello Scott, Thank you for your information. Hope we will have a production release of commons-beanutils2 soon for this to be merged. Sincerely, CHU Minh Toan
My examples were actually the two add behaviour I noticed when trying to pinpoint were the problem was. Here is an example that uses a more explicit content, hoping it will be clearer. This is a single column CSV with two lines, each value having commas and new lines : @Test void test_whenValueIsMonoLine_andOnlyOneChar() throws CsvValidationException, IOException { final String csv = "\"Text with commas, and\r\nnew lines\"\r\n" + "\"Text with commas, and\r\nnew lines\""; final CSVReader reader =...
Strip UTF-8/16 BOM
Sorry this must be a duplicate or something because I swore I responded to this already. I am rejecting this because the purpose of opencsv is to parse csv data. Not csv in utf form or ascii or ebcdic or whatever character formats. It is the duty of the developer using opencsv to handle the vulgarities of whatever file/stream/character types they are using. For UTF characters you can use the apache-commons commons-io BOMInputStream. If you check out the latest code there is an example in BomHandlingTest....
Added tests for Bug261
commons-collections transitive dependency in opencsv:5.10
Hello Kiran First off thanks for the work - I will try and remember your merge when there is a production release of commons-beanutils2. But until there is a production release I am not going to make the change. M2 is a Milestone version - meaning it is potentially feature incomplete, not even a Release Candidate (RC). I have been burned in other projects using non production versions in projects I have worked on so I do everything in my power to not rely on non production versions in my final releases....
Hi, here is my pull request for this update : https://sourceforge.net/p/toan-opencsv/code/ci/updat_to_use_commons-beanutils2/tree/ https://toan@git.code.sf.net/p/toan-opencsv/code updat_to_use_commons-beanutils2 for you to fetch changes up to 75fce13c4ffb0d80c94c54fd9f253f65a02b899f: Update to use commons-beanutils2 (2025-09-05 19:30:19 +0200) Toan Chu (1): Update to use commons-beanutils2 pom.xml | 8 ++++---- src/main/java/com/opencsv/bean/ConverterPrimitiveTypes.java | 8 ++++---- .../bean/customconverter/ConverterLanguageToBoolean.java...
Hello, do you think there will be a next release soon to solve this vulnerability? Thanks
I was also wondering if it could be that you got your original data from a system where the default line separator was \r\n and was processing it on a system where the line separator was \n but in that case both lines should have had a \r in your first test and when I created a copy that did that it passed as well. @Test void test_whenValueIsMonoLine_andOnlyOneCharAndDifferentNewline() throws CsvValidationException, IOException { final String csv = "\"a\"\r\nx\r\n"; final CSVReader reader = new CSVReaderBuilder(new...
Hello Mika Ohhhhhhhkay - thank you for sending the unit test as your expectations in the asserts really clarified to me what you are missing. I will go back to my original statement that what you are sending was not legal csv and that you had to escape the quotation marks to make it legal. Now from the asserts I see that you did not want the quotes at all. So the issue is with your literal blocks. If you read https://www.baeldung.com/java-text-blocks you will see that quotes and newlines are automatically...
Hello, I have checked again using the 5.12.0, I still have the issue. I am not sure what is not legal in the examples : they are csvs with one column and two rows. I did some Junit tests that reproduces the two cases, with one passing and one faulty test each, I hope they will make things clearer.
Hello, I have checked again using the 5.12.0, I still have the issue. I am not sure what is not legal in the examples : they are csvs with one column and two rows. I did some Junit tests that reproduces the two cases, with one passing and one faulty test each, I hope they will make things clearer.
Added code from John Sooter for Feature Request 159 showing how to use the BOMInputStream for handling UTF files with the BOM character.
Strip UTF-8/16 BOM
Default StringProcessor
I am closing this ticket. My apologies but as I stated before changing the default behavior is disruptive and I have felt that backlash on many, many occasions so unless it is an actual bug I am extremely hesitant about changing defaults, behaviors, apis.
commons-beanutils update to 1.10.1
Updated to 1.11.0 so closing down this ticket. I am not going to upgrade to commons-beanutils2 because the latest release is still a milestone release (M2). I do not use milestone, beta, or release candidate versions because I have been burned by that in the past so I treat it like a SNAPSHOT version - good to learn from but not for a production release.
Create a git tag for 5.12.0
tagged and pushed :)
Create a git tag for 5.12.0
Thanks for the quick turnaround @sconway!
Thanks, @sconway
Mika please help me understand the string you are trying to parse. If possible please send me a running JUnit test showing your expectations. My issue is when I looked at the following line String csv = """ "ab"\r "x" """; it is not a legal csv line to the CSVParser or the RFC4180Parser. If you want the quotes as part of the data you need to escape it with double quotes. Also please re-run you code using the 5.12.0 release that was just released today. I am wondering if the fix for bug#259 will solve...
Reader with RFC-4180 Parser returns null for blank row
The fix has been merged with version 5.12.0
create version 5.12.1-SNAPSHOT
create version 5.12.0
Version 5.12.0 has been released
What's new
Reader with RFC-4180 Parser returns null for blank row
fixed in 5.12.0 release.
opencsv 5.11.1 includes junit-vintage-engine as a compile-time dependency
fixed in 5.11.2 release.
What's new
Merge /u/amukherjee9/opencsv/ branch master into master
Updated commons-lang3 version for fixing CVE-2025-48924
Merge /u/markussp/opencsv/ branch feature--misc-updates-2 into master
Remove duplicate Maven JAR plugin version definitions
Bug #259 - modify RFC4180Parser to handle lines with no data that was introduced in the fix for Bug#257.
Updated commons-lang3 version for fixing CVE-2025-48924
That's great, thanks. Here's a simple test: public class Bug259Test { @Test public void parseUsingRFC4180Parser() throws IOException { ICSVParser parser = new RFC4180Parser(); assertEquals(Collections.singletonList(""), Arrays.asList(parser.parseLine(""))); } } You can't split something and get nothing, unless you're commons-lang I suppose.
Reader with RFC-4180 Parser returns null for blank row
Will try and create a unit test to duplicate this issue this weekend.
This broke liquibase for some users: https://github.com/liquibase/liquibase/issues/7020
This broke liquibase for somem users: https://github.com/liquibase/liquibase/issues/7020
Finding this bug just cost me half a day :/ An empty string in the input causes the reader to premature stop parsing. If you want to avoid the overhead of using a regex based split in 5.10, then rather than use commons-lang's StringUtils.splitPreserveAllTokens, what about a simple character based split method inside RFC4180Parser, e.g. private String[] tokenizeStringIntoArray(String nextLine) { List<String> tokens = new ArrayList<>(); int nextIndex = 0; while (true) { int lastIndex = nextIndex; nextIndex...
Quote read as part of the value when using keepCarriageReturn
Hello Mika - I will attempt to create a JUnit test that replicates this issue this weekend and work on it as time permits.
Quote read as part of the value when using keepCarriageReturn
Could one of the maintainers please check and merge?
No there is no need. I see the use of it but honestly I am happy when someone has unit tests for the features/fixes in their merge requests and don't want to add any sort of real or imagined complexity.
Thanks for merging. The file showed as an uncommited resource after execution of the tests. I like writing test temp files to a subdir of target/ and name the file after the test class/method. In a test base class you could control whether to clean up after tests or not etc. If this sound interesting I'll put together a pull request.
Remove duplicate Maven JAR plugin version definitions
What's new
Sorry it took so long to merge but I had family in this week :) Thank you for all the work. The only thing I found contentious was the deleteOnExit for files created in unit tests because if there is an issue the files are gone. But that test has been around for years without issue so I just merged it - if an issue ever arises we can just comment out the delete.
Improve build and test setup
Hi Scott, oh ah ... the state of the repo did seem a little odd :) I've closed this merge request (if it can be deleted, please go ahead), forked the correct repo and sent in a new merge request: https://sourceforge.net/p/opencsv/source/merge-requests/39/ Markus
Improve build and test setup
Modernize build setup
Oh Markus I am so sorry. I have been meaning to get rid of the code repo for the longest time since I accidentally created it but never got around to it. All the code for opencsv is in the source repo. https://sourceforge.net/p/opencsv/source/ci/master/tree/ That has the latest code. Please look over it and see if anything is missing.