Parse Kotlin metadata manually to honor nullability and avoid kotlin-metadata-jvm dep
See original GitHub issueVersion: 2.6.0-SNAPSHOT Exception: KotlinNullPointerException Message: Response from {path to my suspend fun…} was null but response body type was declared as non-null
The current structure of my suspend fun in my service interface:
@POST("api/...")
suspend fun request(@Body body: Body): Response?
I’m using Gson for serialization.
Is there a way to declare the response body type as nullable that I’m missing? I’ve tried adding null safety on my response object with ? and @Nullable with no success.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:61
- Comments:29 (8 by maintainers)
Top Results From Across the Web
Null safety | Kotlin
Null safety. Nullable types and non-null types. Kotlin's type system is aimed at eliminating the danger of null references, also known as ...
Read more >Retrofit:responseBodyがnullのsuspend関数を定義する
Parse Kotlin metadata manually to honor nullability and avoid kotlin-metadata-jvm dep · Issue #3075 · square/retrofit.
Read more >Using GSON with Kotlin's Non-Null Types | by Clay Gillman
With more and more people using Kotlin, it was inevitable that programmers would use it alongside the most popular Java JSON library, ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Just in case it helps. I was experiencing the exact same KotlinNPE issue over the last 2 days and after trying Converters and Adapters what really worked was to return
Response<Unit>in the retrofit method declaration.I use Retrofit 2.6.0.
Not currently. I’m working on a parser for Kotlin metadata so we don’t have to depend on a gigantic jar to read one isNullable boolean.
On Thu, Apr 11, 2019, 8:27 PM Aidan Laing notifications@github.com wrote: