Падает приложение, если в чате есть сообщение с файлом
Closed this issue · 2 comments
Здравствуйте!
Импортировал ваше SDK как модуль.
При загрузке чата падает приложение, если в любом из сообщений присутствует файл из-за строки с его размером: ожидает LONG, а приходит ему String.
Task threw exception com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: For input string: "806.4 KB" at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:305) at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:295) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:285) at ru.usedesk.sdk.RuntimeTypeAdapterFactory$1.read(RuntimeTypeAdapterFactory.java:222) at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199) at com.google.gson.Gson.fromJson(Gson.java:888) at com.google.gson.Gson.fromJson(Gson.java:853) at com.google.gson.Gson.fromJson(Gson.java:802) at ru.usedesk.sdk.ResponseProcessorImpl.process(ResponseProcessorImpl.java:32) at ru.usedesk.sdk.UsedeskManager$BaseEventEmitterListener.call(UsedeskManager.java:373) at io.socket.emitter.Emitter.emit(Emitter.java:117) at io.socket.client.Socket.onevent(Socket.java:338) at io.socket.client.Socket.onpacket(Socket.java:289) at io.socket.client.Socket.access$100(Socket.java:24) at io.socket.client.Socket$2$2.call(Socket.java:120) at io.socket.emitter.Emitter.emit(Emitter.java:117) at io.socket.client.Manager.ondecoded(Manager.java:427) at io.socket.client.Manager.access$1600(Manager.java:30) at io.socket.client.Manager$7.call(Manager.java:403) at io.socket.parser.IOParser$Decoder.add(IOParser.java:105) at io.socket.client.Manager.ondata(Manager.java:419) at io.socket.client.Manager.access$1000(Manager.java:30) at io.socket.client.Manager$2.call(Manager.java:370) at io.socket.emitter.Emitter.emit(Emitter.java:117) at io.socket.engineio.client.Socket.onPacket(Socket.java:551) at io.socket.engineio.client.Socket.access$1000(Socket.java:36) at io.socket.engineio.client.Socket$5.call(Socket.java:335) at io.socket.emitter.Emitter.emit(Emitter.java:117) at io.socket.engineio.client.Transport.onPacket(Transport.java:126) at io.socket.engineio.client.transports.Polling.access$700(Polling.java:18) at io.socket.engineio.client.transports.Polling$2.call(Polling.java:127) at io.socket.engineio.parser.Parser.decodePayload(Parser.java:241) at io.socket.engineio.client.transports.Polling._onData(Polling.java:135) at io.socket.engineio.client.transports.Polling.onData(Polling.java:102) at io.socket.engineio.client.transports.PollingXHR$5$1.run(PollingXHR.java:125) at io.socket.thread.EventThread$2.run(EventThread.java:80) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.NumberFormatException: For input string: "806.4 KB" at java.lang.Long.parseLong(Long.java:594) at java.lang.Long.parseLong(Long.java:636) at com.google.gson.JsonPrimitive.getAsLong(JsonPrim E: FATAL EXCEPTION: EventThread Process: com.ginzago.android, PID: 17306 com.google.gson.JsonSyntaxException: java.lang.NumberFormatException: For input string: "806.4 KB" at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:305) at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:295) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129) at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220) at com.google.gson.TypeAdapter.fromJsonTree(TypeAdapter.java:285) at ru.usedesk.sdk.RuntimeTypeAdapterFactory$1.read(RuntimeTypeAdapterFactory.java:222) at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:199) at com.google.gson.Gson.fromJson(Gson.java:888) at com.google.gson.Gson.fromJson(Gson.java:853) at com.google.gson.Gson.fromJson(Gson.java:802) at ru.usedesk.sdk.ResponseProcessorImpl.process(ResponseProcessorImpl.java:32) at ru.usedesk.sdk.UsedeskManager$BaseEventEmitterListener.call(UsedeskManager.java:373) at io.socket.emitter.Emitter.emit(Emitter.java:117) at io.socket.client.Socket.onevent(Socket.java:338) at io.socket.client.Socket.onpacket(Socket.java:289) at io.socket.client.Socket.access$100(Socket.java:24) at io.socket.client.Socket$2$2.call(Socket.java:120) at io.socket.emitter.Emitter.emit(Emitter.java:117) at io.socket.client.Manager.ondecoded(Manager.java:427) at io.socket.client.Manager.access$1600(Manager.java:30) at io.socket.client.Manager$7.call(Manager.java:403) at io.socket.parser.IOParser$Decoder.add(IOParser.java:105) at io.socket.client.Manager.ondata(Manager.java:419) at io.socket.client.Manager.access$1000(Manager.java:30) at io.socket.client.Manager$2.call(Manager.java:370) at io.socket.emitter.Emitter.emit(Emitter.java:117) at io.socket.engineio.client.Socket.onPacket(Socket.java:551) at io.socket.engineio.client.Socket.access$1000(Socket.java:36) at io.socket.engineio.client.Socket$5.call(Socket.java:335) at io.socket.emitter.Emitter.emit(Emitter.java:117) at io.socket.engineio.client.Transport.onPacket(Transport.java:126) at io.socket.engineio.client.transports.Polling.access$700(Polling.java:18) at io.socket.engineio.client.transports.Polling$2.call(Polling.java:127) at io.socket.engineio.parser.Parser.decodePayload(Parser.java:241) at io.socket.engineio.client.transports.Polling._onData(Polling.java:135) at io.socket.engineio.client.transports.Polling.onData(Polling.java:102) at io.socket.engineio.client.transports.PollingXHR$5$1.run(PollingXHR.java:125) at io.socket.thread.EventThread$2.run(EventThread.java:80) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.NumberFormatException: For input string: "806.4 KB" at java.lang.Long.parseLong(Long.java:594) E: at java.lang.Long.parseLong(Long.java:636) at com.google.gson.JsonPrimitive.getAsLong(JsonPrimitive.java:242) at com.google.gson.internal.bind.JsonTreeReader.nextLong(JsonTreeReader.java:229) at com.google.gson.internal.bind.TypeAdapters$11.read(TypeAdapters.java:303) ... 49 more
Если в модели UsedeskFile убрать size или заменить его на String - падать чат перестает, однако, все сообщения, которые были с файлами отсутствуют в массиве сообщений.
Прикладываю json одного из сообщений, из-за которого падает:
{"id":48820804,"text":"","createdAt":"2019-07-15T04:49:53Z","chat":2464664,"type":"client_to_operator","name":"","payload":{"avatar":""},"file":{"content":"https://secure.usedesk.ru/files/156697/16365336/get-chat-comment-files/ZGsxM1Z6aHlNVFE0YlVGNU9WQklVakJOYTJNNVFUMDlPanBZOG1aelFRbU5abzJzSE9CV2I5VGo=","size":"1.28 MB","previewLink":"/upload/temp_files/tickets/180_100/2019_07_15/156697/16365336/3098ff43b56675f9ad82d81c632a0b8a/488208045d2c05f26b833.jpg","canHaveFullLink":true,"fullLink":"/upload/temp_files/tickets/full/2019_07_15/156697/16365336/3098ff43b56675f9ad82d81c632a0b8a/488208045d2c05f26b833.jpg","dataType":"image_preview","fileId":4288036,"file_name":"1563165704232.jpg","name":"1563165704232.jpg","type":""}}
Привет, да, такой баг был, в текущей версии исправлен
Работает, спасибо :)