Runtime NoSuchMethod exception when depending on two different versions between library & project
mayman opened this issue · comments
For my project I depend on a librabry that utilises http4s version 0.23.19. In my project I had the dependnecy set to 0.23.18 before realising that it was the cause for the following issue.
I used an EmberClient to make a request that went through an AuthedMiddleware when I got a NoSuchMethodError
exception at runtime which killed the app.
Once I matched up the http4s dependency versions everything worked just fine - so it appears to be a binary incompatibility between minor versions
[error] at org.http4s.ember.client.internal.ClientHelpers$.$anonfun$elevateSocket$3(ClientHelpers.scala:125)
[error] at scala.Option.fold(Option.scala:263)
[error] at org.http4s.ember.client.internal.ClientHelpers$.$anonfun$elevateSocket$1(ClientHelpers.scala:122)
[error] at cats.effect.kernel.Resource.loop$2(Resource.scala:522)
[error] at cats.effect.kernel.Resource.continue$2(Resource.scala:475)
[error] at cats.effect.kernel.Resource.$anonfun$allocatedCase$5(Resource.scala:526)
[error] at cats.effect.IOFiber.succeeded(IOFiber.scala:1190)
[error] at cats.effect.IOFiber.runLoop(IOFiber.scala:338)
[error] at cats.effect.IOFiber.asyncContinueSuccessfulR(IOFiber.scala:1358)
[error] at cats.effect.IOFiber.run(IOFiber.scala:113)
[error] at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:679)
[error] java.lang.NoSuchMethodError: 'fs2.io.net.tls.TLSParameters org.http4s.ember.core.Util$.mkClientTLSParameters(scala.Option, boolean)'
[error] at org.http4s.ember.client.internal.ClientHelpers$.$anonfun$elevateSocket$3(ClientHelpers.scala:125)
[error] at scala.Option.fold(Option.scala:263)
[error] at org.http4s.ember.client.internal.ClientHelpers$.$anonfun$elevateSocket$1(ClientHelpers.scala:122)
[error] at cats.effect.kernel.Resource.loop$2(Resource.scala:522)
[error] at cats.effect.kernel.Resource.continue$2(Resource.scala:475)
[error] at cats.effect.kernel.Resource.$anonfun$allocatedCase$5(Resource.scala:526)
[error] at cats.effect.IOFiber.succeeded(IOFiber.scala:1190)
[error] at cats.effect.IOFiber.runLoop(IOFiber.scala:338)
[error] at cats.effect.IOFiber.asyncContinueSuccessfulR(IOFiber.scala:1358)
[error] at cats.effect.IOFiber.run(IOFiber.scala:113)
[error] at cats.effect.unsafe.WorkerThread.run(WorkerThread.scala:679)```
Thanks for the report!
Once I matched up the http4s dependency versions everything worked just fine - so it appears to be a binary incompatibility between minor versions
The version of http4s-{core,server,client,ember-core,ember-server,ember-client} must always match exactly. They share internal APIs, which make no public-facing guarantees of compatibility.
@armanbilge Thank you for getting back to me, should the user expect to see a compile time warning of some sorts to let the user know that this could happen?
In this case there was no warnings or anything that popped up
Unfortunately the tooling gives us no way to communicate this information to downstream users.
For example, for http4s Ember client 0.23.19, we'd need a way to specify that the acceptable version range for its http4s-core dependency is precisely 0.23.19-0.23.19, while the acceptable version range for its Cats Effect dependency is any version 3.5.0+.
Thank you for taking the time to answer all the questiions @armanbilge!