Mark Payne created NIFI-10141:
---------------------------------
Summary: JSONRecordSetWriter when unable to write record should
convey its schema in log message
Key: NIFI-10141
URL: https://issues.apache.org/jira/browse/NIFI-10141
Project: Apache NiFi
Issue Type: Bug
Components: Extensions
Reporter: Mark Payne
If the JSON Record Set Writer fails to write out a Record, we get a log message
generated by the following line:
{code:java}
logger.error("Failed to write {} with schema {} as a JSON Object due to {}",
new Object[] {record, record.getSchema(), e.toString(), e}); {code}
This indicates the Record and its schema, but it can lead to confusion if the
Record Writer was created with a different schema. We should also include in
this log message the schema that the Record Writer itself is using.
Otherwise, we end up with output that looks like this:
{code:java}
Failed to write MapRecord[{VER=10000, UDT=1654949958385,
IID=Yzk0ZjUwNDczYjkyM2Q0YjoxNjU0OTQ5OTU4Mzg1,
USI=00016549499409380af094b69c808340, UID=9807013334,
DAT=JGABPMJAY\u00091551868547373\u00091, ROT=0, CAT=sms, DVM=Redmi:Redmi Note 8
Pro, AID=c94f59473b923d4b, LDT=1654949958385}]
with schema [\"AID\" : \"STRING\", \"CAT\" : \"STRING\", \"DAT\" : \"STRING\",
\"DVM\" : \"STRING\", \"IID\" : \"STRING\", \"LDT\" : \"LONG\", \"ROT\" :
\"INT\", \"UDT\" : \"LONG\", \"UID\" : \"STRING\", \"USI\" : \"STRING\",
\"VER\" : \"INT\"]
as a JSON Object due to
org.apache.nifi.serialization.record.util.IllegalTypeConversionException:
Cannot convert value [1654949958385] of type class java.lang.Long to Integer
for field LDT as it causes an arithmetic overflow (the value is too large,
e.g.):
{code}
Here, it's attempting to convert a LONG object to an integer and failing.
However, it's very unclear from this log message why it would attempt to
convert the value {{1654949958385}} to an INT because the schema says it's a
LONG. Eventually, we discovered that the cause is that the Record Writer was
created with a schema indicating the field is an INT, not a LONG.
--
This message was sent by Atlassian Jira
(v8.20.7#820007)