Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NPE при старте сессии #38

Open
xBlackCat opened this issue Jul 24, 2024 · 3 comments
Open

NPE при старте сессии #38

xBlackCat opened this issue Jul 24, 2024 · 3 comments
Assignees

Comments

@xBlackCat
Copy link
Contributor

Версия SDK 1.3.1

Ошибка проявляется, т.к. в приходящем JSON нет поля employe

При старте сессии в логах NPE:

onMessage {"type":"state","status":"aiBot","showInput":false}
New connection state: CONNECTED
Error when parsing message
                 java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.gson.JsonObject com.google.gson.JsonElement.getAsJsonObject()' on a null object reference
                 	at ru.livetex.sdk.logic.EntityMapper$LivetexDialogStateDeserializer.deserialize(EntityMapper.java:163)
                 	at ru.livetex.sdk.logic.EntityMapper$LivetexDialogStateDeserializer.deserialize(EntityMapper.java:155)
                 	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:95)
                 	at com.google.gson.Gson.fromJson(Gson.java:1361)
                 	at com.google.gson.Gson.fromJson(Gson.java:1463)
                 	at com.google.gson.Gson.fromJson(Gson.java:1406)
                 	at ru.livetex.sdk.logic.EntityMapper$LivetexTypeModelDeserializer.deserialize(EntityMapper.java:61)
                 	at ru.livetex.sdk.logic.EntityMapper$LivetexTypeModelDeserializer.deserialize(EntityMapper.java:49)
                 	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:95)
                 	at com.google.gson.Gson.fromJson(Gson.java:1361)
                 	at com.google.gson.Gson.fromJson(Gson.java:1262)
                 	at com.google.gson.Gson.fromJson(Gson.java:1171)
                 	at com.google.gson.Gson.fromJson(Gson.java:1107)
                 	at ru.livetex.sdk.logic.EntityMapper.toEntity(EntityMapper.java:46)
                 	at ru.livetex.sdk.logic.LiveTexMessagesHandler.onMessage(LiveTexMessagesHandler.java:83)
                 	at ru.livetex.sdk.network.websocket.LiveTexWebsocketListener.onMessage(LiveTexWebsocketListener.java:39)
                 	at okhttp3.internal.ws.RealWebSocket.onReadMessage(RealWebSocket.kt:392)
                 	at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.kt:255)
                 	at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:111)
                 	at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:307)
                 	at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
                 	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:529)
                 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
                 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
                 	at java.lang.Thread.run(Thread.java:1012)
@maxxx maxxx self-assigned this Jul 25, 2024
@maxxx
Copy link
Collaborator

maxxx commented Jul 26, 2024

исправил в 1.3.2

@maxxx maxxx closed this as completed Jul 26, 2024
@xBlackCat
Copy link
Contributor Author

xBlackCat commented Sep 2, 2024

Всё ещё есть ошибка при старте сессии, если приходит такое сообщение:

onMessage {
  "type" : "state",
  "status" : "aiBot",
  "employeeStatus" : null,
  "employee" : null,
  "showInput" : false
}

здесь поле employee есть, но содержит null. В результате аналогичный эксепшн:

Error when parsing message
com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Not a JSON Object: null
	at com.google.gson.Gson.fromJson(Gson.java:1372)
	at com.google.gson.Gson.fromJson(Gson.java:1463)
	at com.google.gson.Gson.fromJson(Gson.java:1406)
	at ru.livetex.sdk.logic.EntityMapper$LivetexTypeModelDeserializer.deserialize(EntityMapper.java:61)
	at ru.livetex.sdk.logic.EntityMapper$LivetexTypeModelDeserializer.deserialize(EntityMapper.java:49)
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:95)
	at com.google.gson.Gson.fromJson(Gson.java:1361)
	at com.google.gson.Gson.fromJson(Gson.java:1262)
	at com.google.gson.Gson.fromJson(Gson.java:1171)
	at com.google.gson.Gson.fromJson(Gson.java:1107)
	at ru.livetex.sdk.logic.EntityMapper.toEntity(EntityMapper.java:46)
	at ru.livetex.sdk.logic.LiveTexMessagesHandler.onMessage(LiveTexMessagesHandler.java:83)
	at ru.livetex.sdk.network.websocket.LiveTexWebsocketListener.onMessage(LiveTexWebsocketListener.java:39)
	at okhttp3.internal.ws.RealWebSocket.onReadMessage(RealWebSocket.kt:392)
	at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.kt:255)
	at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:111)
	at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:307)
	at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195)
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:529)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
	at java.lang.Thread.run(Thread.java:1012)
Caused by: java.lang.IllegalStateException: Not a JSON Object: null
	at com.google.gson.JsonElement.getAsJsonObject(JsonElement.java:165)
	at ru.livetex.sdk.logic.EntityMapper$LivetexDialogStateDeserializer.deserialize(EntityMapper.java:164)
	at ru.livetex.sdk.logic.EntityMapper$LivetexDialogStateDeserializer.deserialize(EntityMapper.java:155)
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:95)
	at com.google.gson.Gson.fromJson(Gson.java:1361)
	at com.google.gson.Gson.fromJson(Gson.java:1463) 
	at com.google.gson.Gson.fromJson(Gson.java:1406) 
	at ru.livetex.sdk.logic.EntityMapper$LivetexTypeModelDeserializer.deserialize(EntityMapper.java:61) 
	at ru.livetex.sdk.logic.EntityMapper$LivetexTypeModelDeserializer.deserialize(EntityMapper.java:49) 
	at com.google.gson.internal.bind.TreeTypeAdapter.read(TreeTypeAdapter.java:95) 
	at com.google.gson.Gson.fromJson(Gson.java:1361) 
	at com.google.gson.Gson.fromJson(Gson.java:1262) 
	at com.google.gson.Gson.fromJson(Gson.java:1171) 
	at com.google.gson.Gson.fromJson(Gson.java:1107) 
	at ru.livetex.sdk.logic.EntityMapper.toEntity(EntityMapper.java:46) 
	at ru.livetex.sdk.logic.LiveTexMessagesHandler.onMessage(LiveTexMessagesHandler.java:83) 
	at ru.livetex.sdk.network.websocket.LiveTexWebsocketListener.onMessage(LiveTexWebsocketListener.java:39) 
	at okhttp3.internal.ws.RealWebSocket.onReadMessage(RealWebSocket.kt:392) 
	at okhttp3.internal.ws.WebSocketReader.readMessageFrame(WebSocketReader.kt:255) 
	at okhttp3.internal.ws.WebSocketReader.processNextFrame(WebSocketReader.kt:111) 
	at okhttp3.internal.ws.RealWebSocket.loopReader(RealWebSocket.kt:307) 
	at okhttp3.internal.ws.RealWebSocket$connect$1.onResponse(RealWebSocket.kt:195) 
	at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:529) 
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644) 
	at java.lang.Thread.run(Thread.java:1012) ```

@maxxx maxxx reopened this Sep 4, 2024
@maxxx
Copy link
Collaborator

maxxx commented Sep 4, 2024

в 1.3.3 должно исправиться

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants