diff --git a/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java b/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java index 44b23fe9..8548e64b 100644 --- a/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java +++ b/protocol/src/main/java/com/zfoo/protocol/buffer/ByteBufUtils.java @@ -844,9 +844,9 @@ public abstract class ByteBufUtils { public static Set readByteSet(ByteBuf byteBuf) { var length = readInt(byteBuf); - var set = (Set) CollectionUtils.newFixedSet(length); + var set = new HashByteSet(length); for (var i = 0; i < length; i++) { - set.add(readByteBox(byteBuf)); + set.add(readByte(byteBuf)); } return set; } @@ -930,9 +930,9 @@ public abstract class ByteBufUtils { public static Set readShortSet(ByteBuf byteBuf) { var length = readInt(byteBuf); - var set = (Set) CollectionUtils.newFixedSet(length); + var set = new HashShortSet(length); for (var i = 0; i < length; i++) { - set.add(readShortBox(byteBuf)); + set.add(readShort(byteBuf)); } return set; } @@ -1009,9 +1009,9 @@ public abstract class ByteBufUtils { public static Set readIntSet(ByteBuf byteBuf) { var length = readInt(byteBuf); - var set = (Set) CollectionUtils.newFixedSet(length); + var set = new HashIntSet(length); for (var i = 0; i < length; i++) { - set.add(readIntBox(byteBuf)); + set.add(readInt(byteBuf)); } return set; } @@ -1088,9 +1088,9 @@ public abstract class ByteBufUtils { public static Set readLongSet(ByteBuf byteBuf) { var length = readInt(byteBuf); - var set = (Set) CollectionUtils.newFixedSet(length); + var set = new HashLongSet(length); for (var i = 0; i < length; i++) { - set.add(readLongBox(byteBuf)); + set.add(readLong(byteBuf)); } return set; } diff --git a/protocol/src/test/java/com/zfoo/protocol/collection/FixedCollectionTest.java b/protocol/src/test/java/com/zfoo/protocol/collection/FixedCollectionTest.java index 8e4d21c1..be10445f 100644 --- a/protocol/src/test/java/com/zfoo/protocol/collection/FixedCollectionTest.java +++ b/protocol/src/test/java/com/zfoo/protocol/collection/FixedCollectionTest.java @@ -49,19 +49,18 @@ public class FixedCollectionTest { @Test - public void testFixedHashInt() { - var list = new FixedSizeListInt(3); - list.set(0, 1); - list.set(1, 2); - list.set(2, 4); - var set = new FixedHashSetInt(list); + public void testHashIntSet() { + var set = new HashIntSet(3); + set.add(1); + set.add(2); + set.add(3); for (int i = 0; i < set.size(); i++) { for (var ele : set) { // test iterator } } - Assert.assertTrue(set.contains(4)); + Assert.assertTrue(set.contains(3)); } }