Spaces in Header and CsvBindByName.required
Brought to you by:
aruckerjones,
sconway
Using opencsv 5.7.1.
Before adding (required = true) to @CsvBindByName, my application worked irrespective of spaces around field names in the header line.
After adding (required = true), a CsvRequiredFieldEmptyException is raised if there are any spaces around that field name in the header line.
Please send us a small test application, test csv file we can use to set up an experiment with to narrow down when the change occurred and the best fix? Something we can look at and say this worked in x.y version but fails in x.z version of opencsv.
What version were you using previously? Very curious as most of the required logic was added in 2016-2017. I was trying to see what was added in the last six months and have not found anything yet.
Thank you. Please see attached. I started using opencsv about two years ago with version 5.5.2. I am now on version 5.7.1 but only just recently added (required = true) to some of the @CsvBindByName annotations. Normally I would upgrade to the latest version, but right now I have a corporate network issue that is blocking access to Maven.
I have now upgraded to 5.8, and see the same behaviour.
Thank you for your excellent example I was able to find the issue and I do have a fix for it. There are several places where we trim the field names just for such situations but we do not have a trim where we are checking for required fields - which happens as part of the reading of the header but before we safe off the field names.
The fix is in FieldMapByNames.java and I already have it commited. I will not be creating a new version right away because I want to take your example and make a unit test out of it inside opencsv so if the trim is removed we have a failing test that will notify the remover they are doing something bad.
That's great. Thank you for the fix, and for opencsv in general, a very useful library. Would it be possible to give a rough indication of when the next version is likely to be released?
No promises but I am going to shoot for this weekend. I almost had it in last night but I was getting issues uploading it to sonatype (maven central repository) and I need to resolve that. The earliest I can see myself getting back on my home computer is Thursday but it will probably be this next weekend.
You can clone the repo from sourceforge and build it yourself to test it out.
Scott :)
Excellent, thank you!
Hello James - sorry but this is going to have to be postponed. The Nexus Repository Manager code that is hosted for open source projects at oss.sonatype.org is no longer working so I cannot upload projects to maven central repository. I have a call scheduled with sonatype to figure out what the new way of doing things are because everything I am finding on the internet want me to install a repository manager on my laptop just to upload to maven central and then they want to upsell to the not free pro version :( hopefully there is something I am missing.
Hi Scott, Thanks for letting me know and good luck with the resolution.
I don't know what changed today other than the fact that I was taking screen shots of everything so I could file a Jira with sonatype but it worked and 5.9 has been released.
:)
Awesome, thank you. Works perfectly.