shymmq / librus-client

Klient restowego API librusa na androida
https://play.google.com/store/apps/details?id=pl.librus.client
GNU General Public License v3.0
14 stars 3 forks source link

Error parsing Averages #87

Closed mimi89999 closed 7 years ago

mimi89999 commented 7 years ago

Version: 39bbe93 Device: Samsung Galaxy S4 Mini OS: LineageOS 14.1 (Android 7.1.1)

02-17 21:30:01.763 32741-374/pl.librus.client E/librus-client-log: Error parsing Averages 02-17 21:30:01.763 32741-374/pl.librus.client W/System.err: com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of pl.librus.client.datamodel.Average[] out of NOT_AVAILABLE token 02-17 21:30:01.763 32741-374/pl.librus.client W/System.err: at [Source: N/A; line: -1, column: -1] 02-17 21:30:01.763 32741-374/pl.librus.client W/System.err: at com.fasterxml.jackson.databind.DeserializationContext.reportMappingException(DeserializationContext.java:1234) 02-17 21:30:01.763 32741-374/pl.librus.client W/System.err: at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1122) 02-17 21:30:01.763 32741-374/pl.librus.client W/System.err: at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1075) 02-17 21:30:01.763 32741-374/pl.librus.client W/System.err: at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.handleNonArray(ObjectArrayDeserializer.java:275) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:179) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at com.fasterxml.jackson.databind.deser.std.ObjectArrayDeserializer.deserialize(ObjectArrayDeserializer.java:20) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3770) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2099) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at com.fasterxml.jackson.databind.ObjectMapper.treeToValue(ObjectMapper.java:2596) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at pl.librus.client.api.APIClient.parseList(APIClient.java:66) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at pl.librus.client.api.APIClient.lambda$getList$4(APIClient.java:219) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at pl.librus.client.api.APIClient.access$lambda$5(APIClient.java) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at pl.librus.client.api.APIClient$$Lambda$6.apply(Unknown Source) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at java8.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:630) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at java8.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:468) 02-17 21:30:01.764 32741-374/pl.librus.client W/System.err: at java.lang.Thread.run(Thread.java:761)

mimi89999 commented 7 years ago

So there are tow possibilities:

  1. We implement a data type for the full Account status and from there we get whether averages are available or not

  2. We check if "disabled" is present in Librus response (input to that class (??)) and if it is, not execute the code that causes the issue.

Which one we go for?

shymmq commented 7 years ago

I cannot find anything related to averages in /Units response, so i think we will have to go for the second option. We can also calculate averages ourselves.

śr., 22 lut 2017 o 18:27 użytkownik Michel Le Bihan < notifications@github.com> napisał:

So there are tow possibilities:

1.

We implement a data type for the full Account status and from there we get whether averages are available or not 2.

We check if "disabled" is present in Librus response (input to that class (??)) and if it is, not execute the code that causes the issue.

Which one we go for?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/shymmq/librus-client/issues/87#issuecomment-281740166, or mute the thread https://github.com/notifications/unsubscribe-auth/AIH1mTiiQUrMYEs-KV2rtOQYKhBrvij9ks5rfHANgaJpZM4MEuN4 .

mimi89999 commented 7 years ago

I will go for checking if disabled is present.

rowysock commented 7 years ago

That's not the ideal solution as "disabled" keyword can theoretically be a part of a normal response. I would rather suggest checking for root / topLevel property. If it isn't there, try to parse response as an error an only then check for disabled keyword

mimi89999 commented 7 years ago

So we can compare the input with exact response of Librus when averages aren't available (or hashes of replies).

mimi89999 commented 7 years ago

@rowysock if (topLevelName.equals("Averages") && input.contains("Disabled")) { What do you think?