You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Tsz-wo Sze (Jira)" <ji...@apache.org> on 2026/03/07 21:59:00 UTC
[jira] [Created] (HDDS-14788) Avoid using guava Ints to convert byte arrays
Tsz-wo Sze created HDDS-14788:
---------------------------------
Summary: Avoid using guava Ints to convert byte arrays
Key: HDDS-14788
URL: https://issues.apache.org/jira/browse/HDDS-14788
Project: Apache Ozone
Issue Type: Sub-task
Components: common, SCM HA
Reporter: Tsz-wo Sze
As shown in the test below, Guava Ints is the same as ByteBuffer. It is better to just use standard Java library.
{code}
@Test
public void testInts() {
for(int i = 0; i < 1000; i++) {
final int original = ThreadLocalRandom.current().nextInt();
final byte[] ints = Ints.toByteArray(original);
final ByteBuffer buffer = ByteBuffer.allocate(4);
buffer.putInt(original);
buffer.flip();
assertArrayEquals(ints, buffer.array());
assertEquals(original, Ints.fromByteArray(ints));
assertEquals(original, buffer.getInt());
}
}
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org