"I guess if List type of AngularObject is updated from front-end" --> It is very possible now with my PR #678
I suggest that we add a last step to catch all types other than String (or we can remove completely the String case) : value = gson.fromJson(object) On Thu, Jan 28, 2016 at 7:40 AM, moon soo Lee <m...@apache.org> wrote: > Good catch. I guess if List type of AngularObject is updated from > front-end, interpreter process can not not correctly deserialize it. > So shell we add deserialize as a List before deserialize as a String? > > And right, value can be anything, not necessarily a String. > > On Thu, Jan 28, 2016 at 7:14 AM DuyHai Doan <doanduy...@gmail.com> wrote: > > > "deserialize as a Map, and if it fails, it try to deserialize as a String > > (in > > the next statements)." > > > > --> But why a String for the last attempt of deserialization ? What will > > happen if I send a List<Integer> as a value for the AngularObject ? > > > > After all, by looking at the definition of an AngularObject, the value > can > > be anything (type parameter T), not necessarily a String right ? > > > > public class AngularObject<T> { > > private String name; > > private T object; > > > > > > And yes, I'm going to review your resource pool PR, it looks promising > > > > > > > > > > > > > > On Wed, Jan 27, 2016 at 11:01 PM, moon soo Lee <m...@apache.org> wrote: > > > > > Hi, > > > > > > When deserializing AngularObject, RemoteInterpreterServer first try to > > > deserialize as a Map, and if it fails, it try to deserialize as a > String > > > (in the next statements). > > > > > > So the exception should be muted, as it's just expected exception while > > > guessing the type. > > > > > > I've made commit for muting this expected exception > > > > > > > > > https://github.com/Leemoonsoo/incubator-zeppelin/commit/0af0cd03236faac63cae17cfc4a4d9b4f76692ca > > > and the commit is included in > > > https://github.com/apache/incubator-zeppelin/pull/655 > > > > > > I think PR-655 is ready to be merged. DuyHai Doan, could you review the > > PR? > > > > > > Thanks, > > > moon > > > > > > On Wed, Jan 27, 2016 at 11:41 PM DuyHai Doan <doanduy...@gmail.com> > > wrote: > > > > > > > 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 ? > > > > > > > > > >