Skip to content

Commit db2a17f

Browse files
author
Quintin Willison
committed
Revert some of the manual JSON deserialisation code I injected as it was causing REST crypto tests for text protocol to fail.
1 parent deb0f59 commit db2a17f

2 files changed

Lines changed: 2 additions & 11 deletions

File tree

lib/src/main/java/io/ably/lib/types/Message.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ static Message fromMsgpack(MessageUnpacker unpacker) throws IOException {
173173
*/
174174
public static Message fromEncoded(JsonObject messageJson, ChannelOptions channelOptions) throws MessageDecodeException {
175175
try {
176-
final Message message = new Message();
177-
message.read(messageJson);
176+
Message message = Serialisation.gson.fromJson(messageJson, Message.class);
178177
message.decode(channelOptions);
179178
return message;
180179
} catch(Exception e) {

lib/src/main/java/io/ably/lib/types/MessageSerializer.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,7 @@ static void writeMsgpackArray(Message.Batch[] pubSpecs, MessagePacker packer) th
136136
****************************************/
137137

138138
public static Message[] readMessagesFromJson(byte[] packed) throws MessageDecodeException {
139-
final InputStream stream = new ByteArrayInputStream(packed);
140-
final Reader reader = new InputStreamReader(stream);
141-
final JsonElement root = JsonParser.parseReader(reader);
142-
143-
if (!(root instanceof JsonArray)) {
144-
throw MessageDecodeException.fromDescription("Expected a JSON array but found type \"" + root.getClass() + "\".");
145-
}
146-
147-
return Message.fromEncodedArray((JsonArray)root, null);
139+
return Serialisation.gson.fromJson(new String(packed), Message[].class);
148140
}
149141

150142
/****************************************

0 commit comments

Comments
 (0)