Skip to content

Commit c5231cf

Browse files
Jan Burkhardtcpovirk
authored andcommitted
fixes serialization errors when serializing a
RegularImmutableAsList the issue occur when ImmutableList is included in gwt's serialization policy and ImmutableSet not and a list created by ImmutableSet.asList needs to be serialized Fixes #2614 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=137724815
1 parent 55524c6 commit c5231cf

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

‎guava-gwt/src/com/google/common/collect/RegularImmutableAsList_CustomFieldSerializer.java‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,11 @@
2020
import com.google.gwt.user.client.rpc.SerializationException;
2121
import com.google.gwt.user.client.rpc.SerializationStreamReader;
2222
import com.google.gwt.user.client.rpc.SerializationStreamWriter;
23+
import com.google.gwt.user.client.rpc.core.java.util.Collection_CustomFieldSerializerBase;
24+
import java.util.ArrayList;
2325

2426
/**
25-
* This class implements the server-side GWT serialization of
26-
* {@link RegularImmutableAsList}.
27+
* This class implements the GWT serialization of {@link RegularImmutableAsList}.
2728
*
2829
* @author Hayward Chan
2930
*/
@@ -35,15 +36,14 @@ public static void deserialize(
3536

3637
public static RegularImmutableAsList<Object> instantiate(SerializationStreamReader reader)
3738
throws SerializationException {
38-
@SuppressWarnings("unchecked") // serialization is necessarily type unsafe
39-
ImmutableCollection<Object> delegateCollection = (ImmutableCollection) reader.readObject();
40-
ImmutableList<?> delegateList = (ImmutableList<?>) reader.readObject();
41-
return new RegularImmutableAsList<Object>(delegateCollection, delegateList);
39+
ArrayList<Object> elements = new ArrayList<Object>();
40+
Collection_CustomFieldSerializerBase.deserialize(reader, elements);
41+
ImmutableList<Object> delegate = ImmutableList.copyOf(elements);
42+
return new RegularImmutableAsList<Object>(delegate, delegate);
4243
}
4344

4445
public static void serialize(SerializationStreamWriter writer, RegularImmutableAsList<?> instance)
4546
throws SerializationException {
46-
writer.writeObject(instance.delegateCollection());
47-
writer.writeObject(instance.delegateList());
47+
Collection_CustomFieldSerializerBase.serialize(writer, instance);
4848
}
4949
}

0 commit comments

Comments
 (0)