softwaremill / sttp

The Scala HTTP client you always wanted!
https://sttp.softwaremill.com
Apache License 2.0
1.45k stars 304 forks source link

Reflective Access Error for AsyncHttpClientZioBackend #492

Closed tampler closed 4 years ago

tampler commented 4 years ago

Hello I'm playing with AsyncHttpClientZioBackend. I'm getting an error inside your model. OpenJDK 11 scala 2.13.1 sttp 2.0.7 Here's the message:

java.lang.UnsupportedOperationException: Reflective setAccessible(true) disabled
    at io.netty.util.internal.ReflectionUtil.trySetAccessible(ReflectionUtil.java:31)
    at io.netty.util.internal.PlatformDependent0$4.run(PlatformDependent0.java:225)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:219)
    at io.netty.util.internal.PlatformDependent.isAndroid(PlatformDependent.java:289)
    at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:92)
    at io.netty.util.HashedWheelTimer.<init>(HashedWheelTimer.java:109)
    at io.netty.util.HashedWheelTimer.<init>(HashedWheelTimer.java:218)
    at io.netty.util.HashedWheelTimer.<init>(HashedWheelTimer.java:197)
    at io.netty.util.HashedWheelTimer.<init>(HashedWheelTimer.java:179)
    at io.netty.util.HashedWheelTimer.<init>(HashedWheelTimer.java:163)
    at org.asynchttpclient.DefaultAsyncHttpClient.newNettyTimer(DefaultAsyncHttpClient.java:97)
    at org.asynchttpclient.DefaultAsyncHttpClient.<init>(DefaultAsyncHttpClient.java:87)
    at sttp.client.asynchttpclient.AsyncHttpClientBackend$.defaultClient(AsyncHttpClientBackend.scala:381)
    at sttp.client.asynchttpclient.zio.AsyncHttpClientZioBackend$.$anonfun$apply$1(AsyncHttpClientZioBackend.scala:47)

I also tried to enable Reflective Calls globally with -language:reflectiveCalls but that didn't help. Any ideas ? @adamw

adamw commented 4 years ago

Is it just when constructing the backend? Or you doing anything more? Also, which OS - who knows, maybe that's a factor as well :)

Did this happen before, or is it a new issue with 2.0.7?

tampler commented 4 years ago
  1. OS - Ubuntu 18.04 and 19.10
  2. Never tried before, that's my first experience with sttp and tapir
  3. That's a runtime issue

Let me prepare and upload the code

tampler commented 4 years ago

Here's the project: https://github.com/FSF-Tech/tetra-back Reproduce:

> reStart (in Linux console)
> run the RoutesSpec from your IDE (VScode or IntelliJ)

You will see that test and sttp works fine, but the dump gives this error despite reflectiveCalls being enabled globally Let me know if I can help to debug this

adamw commented 4 years ago

This looks like a netty problem, nothing specific to sttp, or even async-http-client. Indeed, googling the problem leads to: https://github.com/netty/netty/issues/7817

Is what you are seeing a DEBUG-level log message maybe? Does the client work, despite this being reported?

tampler commented 4 years ago

Hi Adam

Yes, that was in a DEBUG mode. I assembled my backend with Tapir and sttp and will upload a template on the ZIO Resources page. Thanks for your support! Thanks for building such awesome tools! Looking forward meeting you in person on some venue

Boris

adamw commented 4 years ago

Thanks as well! Likewise, though meeting anybody in person these days seems like a quite remote possibility ;)