https://kotlinlang.org logo
#kotlin-fuel
Title
# kotlin-fuel
i

itnoles

06/28/2019, 3:42 AM
@Derk-Jan Karrenbeld I am trying to run test on Fuel 3x on Forge, I get very weird errors from One of deserialize(ByteArray) or deserialize(InputStream) or deserialize(Reader) or deserialize(String) must be implemented
d

Derk-Jan Karrenbeld

06/28/2019, 3:45 AM
Is one of those implemented?
i

itnoles

06/28/2019, 3:45 AM
Yes
suspend inline fun <reified T : Any> Request.awaitResponseResultObject(noinline deserializer: JSON.() -> DeserializedResult<T>) = awaitResponseResult(forgeDeserializerOf(deserializer))
d

Derk-Jan Karrenbeld

06/28/2019, 3:45 AM
That looks different
i

itnoles

06/28/2019, 3:46 AM
it supposed to be 🙂
i

itnoles

06/28/2019, 3:47 AM
it is very tough to see which one occurs 😞
d

Derk-Jan Karrenbeld

06/28/2019, 3:48 AM
You need to either implement
Deserializable
and overwrite
fun deserialize(response: Response): T
, or implement
ResponseDeserializable
and override one of the methods
Copy code
suspend inline fun <reified T : Any> Request.awaitResponseResultObject(noinline deserializer: JSON.() -> DeserializedResult<T>) =
   awaitResponseResult(forgeDeserializerOf(deserializer))
doesn't seem to do either of that?
if I commit it with latest changes, would you figure out why?
💯 1
d

Derk-Jan Karrenbeld

06/28/2019, 10:54 AM
Yes, commit and I'll try to figure out what's wrong!
i

itnoles

06/28/2019, 7:37 PM
When I did println(String(response.data)), I see json. Odd. Something must be on deserialize
d

Derk-Jan Karrenbeld

06/28/2019, 7:37 PM
Yeah, that is interesting!
i

itnoles

06/28/2019, 7:42 PM
Now I did override fun deserialize(content: String): T? { println(content) return Forge.modelFromJson(content, deserializer).component1() } I see another json lines.
I think that compontent1() is null, so it throws
d

Derk-Jan Karrenbeld

06/28/2019, 7:56 PM
yeah, null is not valid
I think null = interpreted as no implementation
i

itnoles

06/28/2019, 7:57 PM
T? is Optional
may be null 🙂
d

Derk-Jan Karrenbeld

06/28/2019, 7:58 PM
can you make it return a "nothing empty object" thing 😛 ?
see if that fixes it, for now?
i

itnoles

06/28/2019, 7:58 PM
i did val forge = Forge.modelFromJson(content, deserializer) println(forge.compontent2()), it comes up as com.github.kittinunf.forge.core.DeserializedResult$Failure@fe7548
found it com.github.kittinunf.forge.core.PropertyNotFoundException: Property name status is not found
d

Derk-Jan Karrenbeld

06/28/2019, 8:02 PM
so on error you get the INCORRECT error?
on deserialization error you get a weird not implemente error
that's a bug
i

itnoles

06/28/2019, 8:03 PM
since it is throwing exceptions, it is not catching it and return it as null.
d

Derk-Jan Karrenbeld

06/28/2019, 8:03 PM
got it!
sorry 😞
probably my fault
i

itnoles

06/28/2019, 8:04 PM
private val httpBinUserDeserializer = { json: JSON -> ::HttpBinUserAgentModel.create .map(json at "userAgent") .apply(json at "status") } Hmm
I think it is my fault because I switch Triple to Pair.
{"method":"GET","path":"/user-agent","headers":{"TE":["gzip, deflate; q=0.5"],"content-length":["0"],"Accept":["text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2"],"User-Agent":["Java/1.8.0_181"],"Connection":["keep-alive"],"Host":["localhost:54045"]},"reflect":true,"userAgent":"Java/1.8.0_181"} no status
3 Views