Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-5571

PutDatabaseRecord raise error while handle byte array.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.7.1
    • 1.10.0
    • Core Framework
    • None

    Description

      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. 

      ps.setObject(i + 1, values[fieldIndexes.get(i)]); 

       

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

       

      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)]);
      }
      

       

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              musa musarona
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: