提交 1114d838 authored 作者: Thomas Mueller's avatar Thomas Mueller

Converting binary data to UUID was incorrect when the converting more than 31…

Converting binary data to UUID was incorrect when the converting more than 31 bytes. Now always the first 16 bytes are used.
上级 e16e2c6d
...@@ -57,17 +57,17 @@ public class ValueUuid extends Value { ...@@ -57,17 +57,17 @@ public class ValueUuid extends Value {
} }
/** /**
* Get or create a UUID for the given 32 bytes. * Get or create a UUID for the given 16 bytes.
* *
* @param binary the byte array (must be at least 32 bytes long) * @param binary the byte array (must be at least 16 bytes long)
* @return the UUID * @return the UUID
*/ */
public static ValueUuid get(byte[] binary) { public static ValueUuid get(byte[] binary) {
if (binary.length < 32) { if (binary.length < 16) {
return get(StringUtils.convertBytesToString(binary)); return get(StringUtils.convertBytesToString(binary));
} }
long high = Utils.readLong(binary, 0); long high = Utils.readLong(binary, 0);
long low = Utils.readLong(binary, 16); long low = Utils.readLong(binary, 8);
return (ValueUuid) Value.cache(new ValueUuid(high, low)); return (ValueUuid) Value.cache(new ValueUuid(high, low));
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论