You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Matt Burgess (Jira)" <ji...@apache.org> on 2021/01/21 18:30:00 UTC

[jira] [Updated] (NIFI-5571) PutDatabaseRecord raise error while handle byte array.

     [ https://issues.apache.org/jira/browse/NIFI-5571?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Burgess updated NIFI-5571:
-------------------------------
    Summary: PutDatabaseRecord raise error while handle byte array.  (was: org.apache.nifi.processors.standard.PutDatabaseRecord raise error while handle byte array.)

> 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
>            Priority: Major
>
> 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
(v8.3.4#803005)