musarona created NIFI-5571:
------------------------------

             Summary: org.apache.nifi.processors.standard.PutDatabaseRecord 
raise error while handle byte array.
                 Key: NIFI-5571
                 URL: https://issues.apache.org/jira/browse/NIFI-5571
             Project: Apache NiFi
          Issue Type: Bug
          Components: Core Framework
    Affects Versions: 1.7.1
            Reporter: musarona


line no:656

when record has some values,the code uses setObject for any value. that will 
raise error when the value is a Byte Array. 
{code:java}
ps.setObject(i + 1, values[fieldIndexes.get(i)]); {code}
 

to fix the problem ,use AvroTypeUtil.convertByteArray to convert the value to 
byte[] ,then setBytes will work OK.

 
{code:java}
if(field.getDataType().getFieldType() == RecordFieldType.ARRAY){
    // byte need to be converted to bytearray
    ByteBuffer byteBufferValue = 
AvroTypeUtil.convertByteArray((Object[])values[fieldIndexes.get(i)]);
    ps.setBytes(i + 1, byteBufferValue.array());
}else {
    ps.setObject(i + 1, values[fieldIndexes.get(i)]);
}
{code}
 

 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to