airbrake/javabrake

[0.2.0] com.google.gson.JsonSyntaxException

Closed this issue ยท 7 comments

I updated Javabrake from 0.1.6 to 0.2.0, changed new Notifier(projectId, projectKey); to new Notifier(config); and ran my application. I got this:

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:226)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at com.google.gson.Gson.fromJson(Gson.java:897)
	at com.google.gson.Gson.fromJson(Gson.java:846)
	at com.google.gson.Gson.fromJson(Gson.java:817)
	at io.airbrake.javabrake.PollTask.run(PollTask.java:65)
	at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
	at java.base/java.util.TimerThread.run(Timer.java:506)
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:386)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
	... 7 common frames omitted

Any ideas?

@boris-petrov thanks for the report. I released v0.2.1, please let me know if you still have issues. ๐Ÿ™‚

@kyrylo - thank you for the quick response! I'll try it out in the next few days and will let you know if I see any more issues. Thanks!

@kyrylo - unfortunately this still hasn't been fixed. With 0.2.1 I still get:

java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $
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:226)
	at com.google.gson.Gson.fromJson(Gson.java:932)
	at com.google.gson.Gson.fromJson(Gson.java:897)
	at com.google.gson.Gson.fromJson(Gson.java:846)
	at com.google.gson.Gson.fromJson(Gson.java:817)
	at io.airbrake.javabrake.PollTask.run(PollTask.java:68)
	at java.base/java.util.TimerThread.mainLoop(Timer.java:556)
	at java.base/java.util.TimerThread.run(Timer.java:506)
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:386)
	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:215)
	... 7 more

hm, after reading the code, I see that remoteConfig defaults to true. I'm not using a remote config so that's why the exception is thrown. But perhaps a better message would be nice. :)

I think this has been fixed, since as of v0.2.1 the error is being caught. What you see is debug output when the error happens. I will improve the error message and print the config payload so that I can understand what exactly is going on and why that JSON cannot be parsed.

remoteConfig is indeed true by default, but the config is provided for you automatically. No need to "use" it explicitly. The notifier takes care of that behind the scene.

I released v0.2.2 with the improved error message and another minor fix, which might be relevant for this issue. I'd appreciate if you could take a look and see what error you get this time.

@kyrylo - I believe all looks fine now. The error is gone. I saw your changes and they should be enough - you print out what the problem was.

Thanks for the support! I'll let you know if something is not working as expected. :)