Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Add ConcurrentHashMap.KeySetView serializer
  • Loading branch information
bergander committed May 6, 2025
commit 96015bdf588d6144daa7fed992e96bfcaf3dda8a
Original file line number Diff line number Diff line change
Expand Up @@ -855,18 +855,18 @@ private PriorityQueue createPriorityQueue (Class<? extends Collection> type, int

/** Serializer for {@link ConcurrentHashMap.KeySetView}.
* @author Andreas Bergander */
public static class KeySetViewSerializer extends CollectionSerializer<ConcurrentHashMap.KeySetView> {
protected void writeHeader (Kryo kryo, Output output, ConcurrentHashMap.KeySetView set) {
public static class KeySetViewSerializer extends Serializer<ConcurrentHashMap.KeySetView> {
public void write (Kryo kryo, Output output, ConcurrentHashMap.KeySetView set) {
kryo.writeClassAndObject(output, set.getMap());
kryo.writeClassAndObject(output, set.getMappedValue());
}

protected ConcurrentHashMap.KeySetView create (Kryo kryo, Input input, Class<? extends ConcurrentHashMap.KeySetView> type, int size) {
public ConcurrentHashMap.KeySetView read (Kryo kryo, Input input, Class<? extends ConcurrentHashMap.KeySetView> type) {
return createKeySetView((ConcurrentHashMap)kryo.readClassAndObject(input), kryo.readClassAndObject(input));
}

protected ConcurrentHashMap.KeySetView createCopy (Kryo kryo, ConcurrentHashMap.KeySetView original) {
return createKeySetView(original.getMap(), original.getMappedValue());
public ConcurrentHashMap.KeySetView copy (Kryo kryo, ConcurrentHashMap.KeySetView original) {
return createKeySetView(kryo.copy(original.getMap()), kryo.copy(original.getMappedValue()));
}

private ConcurrentHashMap.KeySetView createKeySetView (ConcurrentHashMap map, Object mappedValue) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ void testConcurrentHashMapKeySetView () {
set.add(12);
kryo.register(ConcurrentHashMap.KeySetView.class, new KeySetViewSerializer());
kryo.register(ConcurrentHashMap.class);
roundTrip(13, set);
roundTrip(9, set);
}

@Test
Expand All @@ -474,15 +474,15 @@ void testConcurrentHashMapKeySetViewFromExistingMap () {

kryo.register(ConcurrentHashMap.KeySetView.class, new KeySetViewSerializer());
kryo.register(ConcurrentHashMap.class);
roundTrip(22, set);
roundTrip(15, set);
}

@Test
void testEmptyConcurrentHashMapKeySetView () {
ConcurrentHashMap.KeySetView set = ConcurrentHashMap.newKeySet();
kryo.register(ConcurrentHashMap.KeySetView.class, new KeySetViewSerializer());
kryo.register(ConcurrentHashMap.class);
roundTrip(6, set);
roundTrip(5, set);
}

@Test
Expand Down