In Jackson 2.10.2 the standard deserializer converts empty strings and all-whitespace strings to zero when deserializing to ints. In 2.12 the default behavior changed: it accepts blank strings but not all-whitespace strings. I imagine this is related to the changes to leniency handling in 2.12. While it's great to be able to configure leniency, for backwards compatibility the library should maintain the old default behavior.
Test case:
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
@JsonDeserialize
public class Jack {
private final int j;
@JsonCreator
public Jack(@JsonProperty("J") int j) {
this.j = j;
}
private static void test(String s) {
final String json = "{ \"J\" : \"" + s + "\" }";
try {
final Jack jack = new ObjectMapper().readValue(json, Jack.class);
System.out.println("j=" + jack.j);
} catch (Throwable t) {
t.printStackTrace();
}
}
public static void main(String[] args) {
// With Jackson 2.10.2 these all print j=0
test("0");
test("0 ");
test(" 0");
test(" 0 ");
test("");
// With Jackson 2.12.4 these throw InvalidFormatException
test(" ");
test(" ");
test("\\n");
}
}
Expected behavior: the default deserializer should behave consistently in 2.10 and 2.12.
Actual behavior: the 2.12 deserializer is less lenient and rejects non-empty strings that contain only whitespace.
In Jackson 2.10.2 the standard deserializer converts empty strings and all-whitespace strings to zero when deserializing to ints. In 2.12 the default behavior changed: it accepts blank strings but not all-whitespace strings. I imagine this is related to the changes to leniency handling in 2.12. While it's great to be able to configure leniency, for backwards compatibility the library should maintain the old default behavior.
Test case:
Expected behavior: the default deserializer should behave consistently in 2.10 and 2.12.
Actual behavior: the 2.12 deserializer is less lenient and rejects non-empty strings that contain only whitespace.