`FAIL_ON_NULL_FOR_PRIMITIVES` failure does not indicate field name in exception message
See original GitHub issuepublic class Test {
private String type;
private long num;
@JsonCreator
public Test(@JsonProperty(value = "type", required = true) String type,
@JsonProperty(value = "num", required = true) long num) {
this.type = type;
this.num = num;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public long getNum() {
return num;
}
public void setNum(long num) {
this.num = num;
}
}
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true);
try {
String json = "{ \"type\" : \"number\", \"num\":null }";
Test car = objectMapper.readValue(json, Test.class);
System.out.println(car.getNum());
} catch (MismatchedInputException ex) {
ex.getPath().forEach(it -> System.out.println("field: " + it.getFieldName()));
}
shows field: num
but missing field in json
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES, true);
try {
String json = "{ \"type\" : \"number\" }";
Test car = objectMapper.readValue(json, Test.class);
System.out.println(car.getNum());
} catch (MismatchedInputException ex) {
ex.getPath().forEach(it -> System.out.println("field: " + it.getFieldName()));
}
shows nothing
Please add filed name and in this case.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
jsf 2 - Include field name in error messages generated by ...
I do specify the label attribute - still doesn't get the field name through. (I'm using PrimeFaces 3.0.1 inputText rather than h:inputText, but...
Read more >Kusto.Ingest errors & exceptions - Azure Data Explorer
Any error during the ingestion handling on the client side is indicated by a C# exception. Failures. KustoDirectIngestClient exceptions. While ...
Read more >SQL error messages and exceptions - Oracle Help Center
The column <columnName> on table <tableName> has been modified by adding a not null constraint. 01504, The new index is a duplicate of...
Read more >10.2 Exceptions - Racket Documentation
Creates an exn:fail:contract value and raises it as an exception. The name argument is used as the source procedure's name in the error...
Read more >Error handling with DynamoDB - AWS Documentation
It also describes error messages and codes that are specific to Amazon DynamoDB. ... If you are not using an AWS SDK, you...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@raderio Actually, come to think of it bit more, I wonder if I was wrong. Reference mentions “field” or “key”, in Java context, and not in input source.
I’ll have to think bit more about this after all, since that being the case, it is not unreasonable it would be populated if there is sufficient information to do so.
I also encountered this issue and wanted to report this. I have a potential fix ready and will create a PR soon