Serguey Asael Shinder: String.split silently drops trailing empty fields, and CSV is where it hurts
A CSV row with empty trailing columns loses them:
"alice,dublin,,".split(",") // length 2: ["alice", "dublin"]
"alice,,,".split(",") // length 1: ["alice"]
",,,".split(",") // length 0: an empty array
Nothing throws. The row simply arrives with fewer fields than the header promised, and the code that indexes fields[3] fails somewhere else entirely, on a row that looked fine in the file.
This is documented behaviour, not a bug. The javadoc for the one-argument split:
"This method works as if by invoking the two-argument split method with the given expression and a limit argument of zero. Trailing empty strings are therefore not included in the resulting array."

And for the two-argument form:
"If the limit is zero then the pattern will be applied as many times as possible, the array can have any length, and trailing empty strings will be discarded."
The fix is a negative limit. Any negative value means "apply the pattern as many times as possible and keep everything":
String[] fields = line.split(",", -1); // ["alice", "dublin", "", ""]
-1 is the idiom; the value is not a count, only the sign matters for this purpose.
Two things worth keeping next to this one.
Leading empties are kept, which is why the bug hides. ",alice".split(",") gives ["", "alice"] — length 2. So a developer who tests a row with an empty first column concludes that empty fields are preserved, and ships.
split takes a regular expression, not a delimiter. "1.2.3".split(".") returns an empty array, because . matches everything. The delimiter has to be escaped (split("\\.")) or built with Pattern.quote. Since Java 21 there is also splitWithDelimiters, which keeps the matched separators in the returned array — useful when you have to rebuild the original string exactly.
⚠ And the general point: split is not a CSV parser. It has no idea about quoted fields containing the delimiter, and a -1 limit does not give it one.
Reference: https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html