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: [email protected]
For additional commands, e-mail: [email protected]