question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changelog of version 2.5.0 is misleading regarding Unit support

See original GitHub issue

Quoting the changelog:

New: Built-in support for Kotlin’s Unit type. This behaves the same as Java’s Void where the body content is ignored and immediately discarded.

If you try to use a suspending function returning no meaningly value (i.e. Unit), with a backend sending a 204 No-Content response for example, you end up with a runtime failure: the infamous KotlinNullPointerException.

To me, this is quite contradictory with changelog of version 2.5.0, and it’s unclear how Unit is supported.

Also, the test for Kotlin’s Unit is not actually written in Kotlin.

The suspending functions support test is in Kotlin, but it doesn’t test no return value (Unit) in the service proxied by Retrofit. If it is not supported, it’d good to have it written clearly somewhere (along with new doc for Kotlin usage?), and a test that is asserting it fails with KNPE would be good. I lost hours of my time trying to understand why it doesn’t pick the built-in Unit converter, and still don’t have an answer, hours I’d have preferred to spend on something more useful. I prefer to not imagine how beginners would face this.

If support is not there yet, I can submit a doc update PR.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
PaulWoitaschekcommented, Oct 7, 2019

There may be less folks in my situation that I initially thought then.

Well for my application every single PUT has no body so a function like this:

suspend fun putSomething(@Body something : Something)

Is the perfect representation of that call. I assume this is quite a common case.

1reaction
LouisCADcommented, Jun 7, 2019

Now I’m understanding my past experiences, where I had a custom awaitSuccess() extension function before built-in non 204/205 Unit support was integrated. When I updated, I tried and it didn’t work, so I did a quick revert and forgot about it.

There may be less folks in my situation that I initially thought then.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release Notes - Kafka - Version 2.5.0
For full documentation of the release, a guide to get started, and information about the project, see the Kafka project site. Note about...
Read more >
ChangeLog - Moved to GitHub releases — python-gitlab 2.5.0 ...
Add support for pipeline schedules and schedule variables · Clarify information about supported python version · Add manager for jobs within a pipeline...
Read more >
OpenDJ 2.5.0-Xpress1 > Release Notes - ForgeRock Backstage
Notes covering OpenDJ hardware and software requirements, fixes, known issues.
Read more >
Marway Smart PDU Software Version History
Any version from 2.0.0 through 2.2.0 can be updated to 2.2.1. It is not necessary to go through sequentially incremental updates. It is...
Read more >
NEWS-2.5.0 - Freeciv - Fandom
Thanks again to all our developers, who continue to work so hard. This release includes lots of changes relative to 2.4.x; the significant...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found