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/06/22 15:08:00 UTC
[jira] [Resolved] (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 resolved NIFI-5571.
--------------------------------
Fix Version/s: 1.10.0
Resolution: Fixed
Resolving this as I believe it to be superceded by NIFI-6409, please reopen if that is not the case.
> 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
> Fix For: 1.10.0
>
>
> 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)