-
-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Empty Lists can only be String-typed in CSV #199
Comments
Thank you for reporting this -- sounds like a bug -- and big thank you for providing full reproduction too! |
One quick note: I think changing type to |
I'll try that out on monday. Our current workaround is two steps:
|
Ok I can see why this happens. Good thing is that I think I know how to fix is, but I am not yet sure if I can do it in safe enough way to include in 2.11(.1), or if it needs to go in 2.12 (bigger changes, higher regression risk). Longer story is that formats like CSV and XML with no native notion of strong typing (at least wrt List/array constructs) will need to rely on Anyway: I'll see what I can do here. Thank you again for reporting this case! |
Sigh. For a moment I thought fix was simply and could go in 2.11 of So I think I will need to devise a bit bigger fix to be done in 2.12. |
Fixed for 2.12.0. In the meantime, work-arounds include:
|
When mapping POJOs that contain Lists to CSV, Jackson fails with an exception if that list is empty, and the type of the list is not String:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `java.util.ArrayList` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('') at [Source: (com.fasterxml.jackson.dataformat.csv.impl.UTF8Reader); line: 2, column: 1] (through reference chain: de.slevermann.jackson.csv.Model["LONGS"])
I've provided example code with a failing and a succeeding test case over at https://github.com/sonOfRa/jackson-csv-bug.
I'll provide a shortened version here so it's also preserved in an issue. The following CSV:
successfully gets read by Jackson into the following POJO (getters and setters omitted):
The list is empty, and the other field contains "Hello".
However, with the following CSV:
Jackson produces the above exception, when attempting to read into the following POJO:
The text was updated successfully, but these errors were encountered: