ojrlopez27/multiuser-framework

Improve handling of non-JSON messages like SESSION_CLOSED

Closed this issue · 1 comments

Currently, messages of type "SESSION_CLOSED" seem to only be bare strings, as they cause the following exception when using the MUF method edu.cmu.inmind.multiuser.controller.common.Utils.fromJson(String):

com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:224)
	at com.google.gson.Gson.fromJson(Gson.java:887)
	at com.google.gson.Gson.fromJson(Gson.java:852)
	at com.google.gson.Gson.fromJson(Gson.java:801)
	at com.google.gson.Gson.fromJson(Gson.java:773)
	at edu.cmu.inmind.multiuser.controller.common.Utils.fromJson(Utils.java:224)
	at edu.cmu.inmind.multiuser.mockclient.MultiuserClient$1.process(MultiuserClient.java:63)
	at edu.cmu.inmind.multiuser.communication.ClientCommController$ReceiverThread.run(ClientCommController.java:583)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
	at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:385)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:213)
	... 10 more
java.lang.NullPointerException
	at edu.cmu.inmind.multiuser.mockclient.MultiuserClient$1.process(MultiuserClient.java:64)
	at edu.cmu.inmind.multiuser.communication.ClientCommController$ReceiverThread.run(ClientCommController.java:583)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
2018-05-21 12:09:39,815 INFO    ClientCommController           - Closing ClientCommController...

Either all messages should be in valid JSON format or there should be a higher-level MUF method called something like unmarshalMessage(String) that handles the possible different content formats of the different messages.

@errantlinguist issue is fixed and new muf version: 3.0.15.1-rc1