I encountered the following exception when pushing an AngularObject to a
remote interpreter:


INFO [2016-01-27 15:25:41,433] ({pool-1-thread-4}
RemoteInterpreterServer.java[angularObjectAdd]:598) - Exception in
RemoteInterpreterServer while deserializing "James BOND" in
angularObjectAdd, nolock
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException:
Expected BEGIN_OBJECT but was STRING at line 1 column 13
at com.google.gson.Gson.fromJson(Gson.java:802)
at com.google.gson.Gson.fromJson(Gson.java:757)
at com.google.gson.Gson.fromJson(Gson.java:706)
at
org.apache.zeppelin.interpreter.remote.RemoteInterpreterServer.angularObjectAdd(RemoteInterpreterServer.java:593)
at
org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService$Processor$angularObjectAdd.getResult(RemoteInterpreterService.java:1289)
at
org.apache.zeppelin.interpreter.thrift.RemoteInterpreterService$Processor$angularObjectAdd.getResult(RemoteInterpreterService.java:1274)
at org.apache.thrift.ProcessFunction.process(ProcessFunction.java:39)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:39)
at
org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:285)
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:745)
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was
STRING at line 1 column 13
at com.google.gson.stream.JsonReader.expect(JsonReader.java:339)
at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:322)
at
com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:184)
at
com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:146)
at com.google.gson.Gson.fromJson(Gson.java:791)


Looking into the source code of RemoteInterpreterServer :

 @Override
  public void angularObjectAdd(String name, String noteId, String
paragraphId, String object) {

  try {
      value = gson.fromJson(object,
          new TypeToken<Map<String, Object>>() {
          }.getType());
    } catch (Exception e) {
      // nolock
      logger.info(String.format("Exception in RemoteInterpreterServer while
deserializing %s " +
        "in angularObjectAdd, nolock", object), e);
    }
  }

The issue is because we try to tell GSON to deserialize the object and we
expect the type Map<String, Object>. There is no reason that the angular
object value is a map. It can be anything, a String, a Double, a Long ....

 In my example, in the exception stack trace, the value is just a plain
String "James BOND"

 Should I fill a JIRA and push a quick fix for that ?

Reply via email to