mirror of https://github.com/apache/nifi.git
NIFI-8156 Fixed byte handling bug in cassandra.
Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com> This closes #4771.
This commit is contained in:
parent
fb2a8b5820
commit
953327cdf5
|
@ -52,6 +52,7 @@ import org.apache.nifi.serialization.record.util.DataTypeUtils;
|
|||
import org.apache.nifi.util.StopWatch;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Collection;
|
||||
|
@ -419,7 +420,21 @@ public class PutCassandraRecord extends AbstractCassandraProcessor {
|
|||
insertQuery = QueryBuilder.insertInto(cassandraTable);
|
||||
}
|
||||
for (String fieldName : schema.getFieldNames()) {
|
||||
insertQuery.value(fieldName, recordContentMap.get(fieldName));
|
||||
Object value = recordContentMap.get(fieldName);
|
||||
|
||||
if (value != null && value.getClass().isArray()) {
|
||||
Object[] array = (Object[])value;
|
||||
|
||||
if (array.length > 0 && array[0] instanceof Byte) {
|
||||
Object[] temp = (Object[]) value;
|
||||
byte[] newArray = new byte[temp.length];
|
||||
for (int x = 0; x < temp.length; x++) {
|
||||
newArray[x] = (Byte) temp[x];
|
||||
}
|
||||
value = ByteBuffer.wrap(newArray);
|
||||
}
|
||||
}
|
||||
insertQuery.value(fieldName, value);
|
||||
}
|
||||
return insertQuery;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue