vietj / retrofit-vertx

A highly scalable adapter for Retrofit with Vert.x
Apache License 2.0
31 stars 7 forks source link

Can't configure JSON Mapper results in IllegalStateException message == null #1

Open junglie85 opened 7 years ago

junglie85 commented 7 years ago

I get the following exception when trying to use retrofit-vertx:

Exception in thread "main" java.lang.RuntimeException: java.io.IOException: java.lang.IllegalStateException: message == null
    at io.reactivex.internal.util.ExceptionHelper.wrapOrThrow(ExceptionHelper.java:45)
    at io.reactivex.internal.observers.BlockingMultiObserver.blockingGet(BlockingMultiObserver.java:91)
    at io.reactivex.Single.blockingGet(Single.java:2148)
    at uk.ashleybye.rxweb.TestKt.main(Test.kt:33)
Caused by: java.io.IOException: java.lang.IllegalStateException: message == null
    at com.julienviet.retrofit.vertx.VertxCallFactory$VertxCall.lambda$enqueue$0(VertxCallFactory.java:90)
    at io.vertx.core.impl.FutureImpl.tryFail(FutureImpl.java:170)
    at io.vertx.core.http.impl.HttpClientResponseImpl.handleException(HttpClientResponseImpl.java:270)
    at io.vertx.core.http.impl.HttpClientResponseImpl.handleEnd(HttpClientResponseImpl.java:259)
    at io.vertx.core.http.impl.ClientConnection.handleResponseEnd(ClientConnection.java:361)
    at io.vertx.core.http.impl.ClientHandler.doMessageReceived(ClientHandler.java:80)
    at io.vertx.core.http.impl.ClientHandler.doMessageReceived(ClientHandler.java:38)
    at io.vertx.core.http.impl.VertxHttpHandler.lambda$channelRead$0(VertxHttpHandler.java:71)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:335)
    at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:193)
    at io.vertx.core.http.impl.VertxHttpHandler.channelRead(VertxHttpHandler.java:71)
    at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:122)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
    at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1228)
    at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1039)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:642)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:565)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:479)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:441)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.IllegalStateException: message == null
    at okhttp3.Response$Builder.build(Response.java:431)
    at com.julienviet.retrofit.vertx.VertxCallFactory$VertxCall.lambda$null$1(VertxCallFactory.java:109)
    at io.vertx.core.http.impl.HttpClientResponseImpl$BodyHandler.notifyHandler(HttpClientResponseImpl.java:301)
    at io.vertx.core.http.impl.HttpClientResponseImpl.lambda$bodyHandler$0(HttpClientResponseImpl.java:193)
    at io.vertx.core.http.impl.HttpClientResponseImpl.handleEnd(HttpClientResponseImpl.java:257)
    ... 36 more

This is from the following code (note that exception is the same whether I try to use Moshi or configure Jackson):

fun main(args: Array<String>) {
    val vertx: Vertx = Vertx.vertx()
    val client = vertx.createHttpClient()

    val retrofit: Retrofit = Retrofit.Builder()
            .baseUrl("https://api.tfl.gov.uk/")
            .addConverterFactory(MoshiConverterFactory.create())
            .callFactory(VertxCallFactory(client))
            .addCallAdapterFactory(RxJava2CallAdapterFactory.createAsync())
            .build()

    val tflService: TflService = retrofit.create(TflService::class.java)

    val result = tflService.getAllUndergroundLines().blockingSingle()
    println(result)
}

interface TflService {
    @GET("/Line/Mode/tube")
    fun getAllUndergroundLines(): Observable<List<UndergroundLine>>
}

data class UndergroundLine(val id: String, val name: String)

However, if I remove .callFactory(VertxCallFactory(client)) and in this case just use Moshi, I get my JSON as expected.

Is it possible to configure the JSON mapper being used? Or is this error cause by some other issue?

vietj commented 7 years ago

can you provide a small project that reproduces the issue ?

junglie85 commented 7 years ago

I've just added a vertx-retrofit branch to this example project which reproduces the issue. If you'd like something smaller, let me know.

vietj commented 7 years ago

I will give a try soon and let you know @AshleyByeUK

vietj commented 7 years ago

the build fails for me

* What went wrong:
Execution failed for task ':compileKotlin'.
> Could not resolve all dependencies for configuration ':compileClasspath'.
   > Could not find io.vertx:vertx-rxjava2:3.5.0-SNAPSHOT.
     Searched in the following locations:
         https://jcenter.bintray.com/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/maven-metadata.xml
         https://jcenter.bintray.com/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.pom
         https://jcenter.bintray.com/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.jar
         http://dl.bintray.com/kotlin/ktor/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/maven-metadata.xml
         http://dl.bintray.com/kotlin/ktor/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.pom
         http://dl.bintray.com/kotlin/ktor/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.jar
         file:/Users/.m2/repository/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/maven-metadata.xml
         file:/Users/.m2/repository/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.pom
         file:/Users/.m2/repository/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.jar
     Required by:
         project :
   > Could not find com.github.aesteve:vertx-sse:0.1.
     Searched in the following locations:
         https://jcenter.bintray.com/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.pom
         https://jcenter.bintray.com/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.jar
         http://dl.bintray.com/kotlin/ktor/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.pom
         http://dl.bintray.com/kotlin/ktor/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.jar
         file:/Users/.m2/repository/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.pom
         file:/Users/.m2/repository/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.jar
     Required by:
         project :

if you can tell me how to reproduce the issue precisely it would be great

junglie85 commented 7 years ago

I think it’s already been solved, as per answer to discussion on stackoverflow.

From: Julien Viet notifications@github.com Reply-To: vietj/retrofit-vertx reply@reply.github.com Date: Monday, 26 June 2017 at 06:58 To: vietj/retrofit-vertx retrofit-vertx@noreply.github.com Cc: DELETED EMAIL, Mention mention@noreply.github.com Subject: Re: [vietj/retrofit-vertx] Can't configure JSON Mapper results in IllegalStateException message == null (#1)

the build fails for me

Execution failed for task ':compileKotlin'.

Could not resolve all dependencies for configuration ':compileClasspath'.

Could not find io.vertx:vertx-rxjava2:3.5.0-SNAPSHOT.

 Searched in the following locations:

     https://jcenter.bintray.com/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/maven-metadata.xml

     https://jcenter.bintray.com/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.pom

     https://jcenter.bintray.com/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.jar

     http://dl.bintray.com/kotlin/ktor/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/maven-metadata.xml

     http://dl.bintray.com/kotlin/ktor/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.pom

     http://dl.bintray.com/kotlin/ktor/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.jar

     file:/Users/.m2/repository/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/maven-metadata.xml

     file:/Users/.m2/repository/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.pom

     file:/Users/.m2/repository/io/vertx/vertx-rxjava2/3.5.0-SNAPSHOT/vertx-rxjava2-3.5.0-SNAPSHOT.jar

 Required by:

     project :

Could not find com.github.aesteve:vertx-sse:0.1.

 Searched in the following locations:

     https://jcenter.bintray.com/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.pom

     https://jcenter.bintray.com/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.jar

     http://dl.bintray.com/kotlin/ktor/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.pom

     http://dl.bintray.com/kotlin/ktor/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.jar

     file:/Users/.m2/repository/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.pom

     file:/Users/.m2/repository/com/github/aesteve/vertx-sse/0.1/vertx-sse-0.1.jar

 Required by:

     project :

if you can tell me how to reproduce the issue precisely it would be great

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/vietj/retrofit-vertx/issues/1#issuecomment-310970203, or mute the thread DELETED LINK

junglie85 commented 7 years ago

I just knocked together the following, which reproduces the issue:

import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.ObjectMapper
import com.julienviet.retrofit.vertx.VertxCallFactory
import io.reactivex.Observable
import io.vertx.core.Vertx
import io.vertx.core.http.HttpClientOptions
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.jackson.JacksonConverterFactory
import retrofit2.http.GET

fun main(args: Array<String>) {
    val mapper = ObjectMapper()
    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)

    val client = Vertx.vertx().createHttpClient(HttpClientOptions().setDefaultPort(8081))
    val retrofit: Retrofit = Retrofit.Builder()
            .baseUrl("https://api.tfl.gov.uk/")
            .callFactory(VertxCallFactory(client))
            .addCallAdapterFactory(RxJava2CallAdapterFactory.createAsync())
            .addConverterFactory(JacksonConverterFactory.create(mapper))
            .build()

    val tflRetrofit: TflRetrofit = retrofit.create(TflRetrofit::class.java)

    tflRetrofit
            .getAllUndergroundLines()
            .subscribe { println(it) }
}

interface TflRetrofit {
    @GET("Line/Mode/tube")
    fun getAllUndergroundLines(): Observable<List<TflLine>>
}

data class TflLine(val id: String, val name: String)

Wondering if it is answered by this discussion on StackOverflow? (I'm using v 1.0.1)

vietj commented 7 years ago

can you try with the version that was released today ?

junglie85 commented 7 years ago

I get a different exception when running the example from a previous comment:

io.reactivex.exceptions.OnErrorNotImplementedException: No suitable constructor found for type [simple type, class uk.ashleybye.grpc.TflLine]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
 at [Source: okhttp3.ResponseBody$BomAwareReader@62894779; line: 1, column: 3] (through reference chain: java.util.ArrayList[0])
    at io.reactivex.internal.functions.Functions$14.accept(Functions.java:229)
    at io.reactivex.internal.functions.Functions$14.accept(Functions.java:226)
    at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:72)
    at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onError(BodyObservable.java:72)
    at retrofit2.adapter.rxjava2.CallEnqueueObservable$CallCallback.onFailure(CallEnqueueObservable.java:81)
    at retrofit2.OkHttpCall$1.callFailure(OkHttpCall.java:130)
    at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:114)
    at com.julienviet.retrofit.vertx.VertxCallFactory$VertxCall.lambda$enqueue$0(VertxCallFactory.java:79)
    at io.vertx.core.impl.FutureImpl.tryComplete(FutureImpl.java:126)
    at com.julienviet.retrofit.vertx.VertxCallFactory$VertxCall.lambda$null$1(VertxCallFactory.java:110)
    at io.vertx.core.http.impl.HttpClientResponseImpl$BodyHandler.notifyHandler(HttpClientResponseImpl.java:301)
    at io.vertx.core.http.impl.HttpClientResponseImpl.lambda$bodyHandler$0(HttpClientResponseImpl.java:193)
    at io.vertx.core.http.impl.HttpClientResponseImpl.handleEnd(HttpClientResponseImpl.java:257)
    at io.vertx.core.http.impl.ClientConnection.handleResponseEnd(ClientConnection.java:361)
    at io.vertx.core.http.impl.ClientHandler.doMessageReceived(ClientHandler.java:80)
    at io.vertx.core.http.impl.ClientHandler.doMessageReceived(ClientHandler.java:38)
    at io.vertx.core.http.impl.VertxHttpHandler.lambda$channelRead$0(VertxHttpHandler.java:71)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:335)
    at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:193)
    at io.vertx.core.http.impl.VertxHttpHandler.channelRead(VertxHttpHandler.java:71)
    at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:122)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
    at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1228)
    at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1039)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:642)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:565)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:479)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:441)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class uk.ashleybye.grpc.TflLine]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
 at [Source: okhttp3.ResponseBody$BomAwareReader@62894779; line: 1, column: 3] (through reference chain: java.util.ArrayList[0])
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:255)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1130)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:298)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:133)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:277)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
    at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1578)
    at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1183)
    at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)
    at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
    at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:119)
    at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:218)
    at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:112)
    ... 42 more
Exception in thread "vert.x-eventloop-thread-0" io.reactivex.exceptions.OnErrorNotImplementedException: No suitable constructor found for type [simple type, class uk.ashleybye.grpc.TflLine]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
 at [Source: okhttp3.ResponseBody$BomAwareReader@62894779; line: 1, column: 3] (through reference chain: java.util.ArrayList[0])
    at io.reactivex.internal.functions.Functions$14.accept(Functions.java:229)
    at io.reactivex.internal.functions.Functions$14.accept(Functions.java:226)
    at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:72)
    at retrofit2.adapter.rxjava2.BodyObservable$BodyObserver.onError(BodyObservable.java:72)
    at retrofit2.adapter.rxjava2.CallEnqueueObservable$CallCallback.onFailure(CallEnqueueObservable.java:81)
    at retrofit2.OkHttpCall$1.callFailure(OkHttpCall.java:130)
    at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:114)
    at com.julienviet.retrofit.vertx.VertxCallFactory$VertxCall.lambda$enqueue$0(VertxCallFactory.java:79)
    at io.vertx.core.impl.FutureImpl.tryComplete(FutureImpl.java:126)
    at com.julienviet.retrofit.vertx.VertxCallFactory$VertxCall.lambda$null$1(VertxCallFactory.java:110)
    at io.vertx.core.http.impl.HttpClientResponseImpl$BodyHandler.notifyHandler(HttpClientResponseImpl.java:301)
    at io.vertx.core.http.impl.HttpClientResponseImpl.lambda$bodyHandler$0(HttpClientResponseImpl.java:193)
    at io.vertx.core.http.impl.HttpClientResponseImpl.handleEnd(HttpClientResponseImpl.java:257)
    at io.vertx.core.http.impl.ClientConnection.handleResponseEnd(ClientConnection.java:361)
    at io.vertx.core.http.impl.ClientHandler.doMessageReceived(ClientHandler.java:80)
    at io.vertx.core.http.impl.ClientHandler.doMessageReceived(ClientHandler.java:38)
    at io.vertx.core.http.impl.VertxHttpHandler.lambda$channelRead$0(VertxHttpHandler.java:71)
    at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:335)
    at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:193)
    at io.vertx.core.http.impl.VertxHttpHandler.channelRead(VertxHttpHandler.java:71)
    at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:122)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
    at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
    at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
    at io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1228)
    at io.netty.handler.ssl.SslHandler.decode(SslHandler.java:1039)
    at io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:411)
    at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:248)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:341)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1334)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:363)
    at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:349)
    at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:926)
    at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:129)
    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:642)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:565)
    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:479)
    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:441)
    at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
    at java.lang.Thread.run(Thread.java:748)
Caused by: com.fasterxml.jackson.databind.JsonMappingException: No suitable constructor found for type [simple type, class uk.ashleybye.grpc.TflLine]: can not instantiate from JSON object (missing default constructor or creator, or perhaps need to add/enable type information?)
 at [Source: okhttp3.ResponseBody$BomAwareReader@62894779; line: 1, column: 3] (through reference chain: java.util.ArrayList[0])
    at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:255)
    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.deserializeFromObjectUsingNonDefault(BeanDeserializerBase.java:1130)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:298)
    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:133)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:277)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:249)
    at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:26)
    at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1578)
    at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1183)
    at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)
    at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
    at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:119)
    at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:218)
    at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:112)
    ... 42 more

That's with the following dependencies:

compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.3"
compile "io.vertx:vertx-core:3.4.2"
compile "io.vertx:vertx-web:3.4.2"
compile "io.reactivex.rxjava2:rxkotlin:2.0.3"
compile "com.squareup.retrofit2:retrofit:2.3.0"
compile "com.squareup.retrofit2:adapter-rxjava2:2.3.0"
compile "com.squareup.retrofit2:converter-jackson:2.3.0"
compile "com.julienviet:retrofit-vertx:1.0.2"
junglie85 commented 7 years ago

However, I just had a thought and tried it with a non-data class and it kind of works, but you lose the benefits of a data class, such as automatic toString() and others:

class TflLine() {

    lateinit var id: String
    lateinit var name: String

    constructor(id: String, name: String) : this () {
        this.id = id
        this.name = name
    }

    override fun toString() = "TflLine(id=$id, name=$name)"
}

If I create a data class and add a secondary "default" constructor it works but feels a bit hackey:

data class TflLine(val id: String, val name: String) {
    constructor() : this("", "")
}

I guess that's more of a Java/Kotlin interop thing than a library issue though. Might be worth a note in the README for any other prospective Kotlin users?

vietj commented 5 years ago

do you mind providing such note ?

vietj commented 5 years ago

as PR