MikeThomsen commented on code in PR #6013:
URL: https://github.com/apache/nifi/pull/6013#discussion_r869140911
##########
nifi-commons/nifi-record/src/main/java/org/apache/nifi/serialization/record/util/DataTypeUtils.java:
##########
@@ -233,6 +237,36 @@ public static Object convertType(final Object value, final
DataType dataType, fi
return null;
}
+ private static Object toUUID(Object value) {
+ if (value instanceof String) {
+ try {
+ return UUID.fromString((String)value);
+ } catch (Exception ex) {
+ throw new IllegalTypeConversionException(String.format("Could
not parse %s into a UUID", value), ex);
+ }
+ } else if (value instanceof byte[]) {
+ return uuidFromBytes((byte[])value);
+ } else if (value instanceof Byte[]) {
+ Byte[] array = (Byte[])value;
+ byte[] converted = new byte[array.length];
+ for (int x = 0; x < array.length; x++) {
+ converted[x] = array[x];
+ }
+ return uuidFromBytes(converted);
+ } else {
+ throw new IllegalTypeConversionException(value.getClass() + "
cannot be converted into a UUID");
Review Comment:
I added a null check to the top of the method since nulls should never be
accepted.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]