playframework / playframework/play-ws
Shading does not allow for multiple versions of AHC
Nobody has claimed this yet.
- Dominant language
- Scala
- Stars
- 224
- Forks
- 92
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 28
Description
Are you looking for help?
No.
Play WS Version (2.5.x / etc)
2.6.11
API (Scala / Java / Neither / Both)
Scala
Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)
Linux me 4.11.8-041108-generic #201706290836 SMP Thu Jun 29 12:38:45 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-8u151-b12-0ubuntu0.17.04.2-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
Library Dependencies
"org.asynchttpclient" % "async-http-client" % "2.0.31", // force this version because C* (Cassandra) driver 3.2 pulls in netty 4.0.44
Expected Behavior
Please describe the expected behavior of the issue, starting from the first action.
- play.shaded.ahc.org.asynchttpclient.config.AsyncHttpClientConfigHelper.Config#parsePropertiesFile() should load its resources by using this.getClass().getClassLoader() first
Actual Behavior
Please provide a description of what actually happens, working from the same starting point.
- In 2.6.11 the resources are first loaded from Thread.currentThread().getContextClassLoader();
The problem is that my application has both "org.asynchttpclient" % "async-http-client" % "2.0.31" (to be compatible with Cassandra Java Driver) and the shaded one by Play WS.
The application fails with:
java.lang.NumberFormatException: null
at java.lang.Integer.parseInt(Integer.java:542)
at java.lang.Integer.parseInt(Integer.java:615)
at play.shaded.ahc.org.asynchttpclient.config.AsyncHttpClientConfigHelper$Config.getInt(AsyncHttpClientConfigHelper.java:109)
at play.shaded.ahc.org.asynchttpclient.config.AsyncHttpClientConfigDefaults.defaultMaxRedirects(AsyncHttpClientConfigDefaults.java:64)
at play.shaded.ahc.org.asynchttpclient.DefaultAsyncHttpClientConfig$Builder.<init>(DefaultAsyncHttpClientConfig.java:599)
at play.api.libs.ws.ahc.AhcConfigBuilder.<init>(AhcConfig.scala:127)
at play.api.libs.ws.ahc.StandaloneAhcWSClient$.apply(StandaloneAhcWSClient.scala:153)
at play.api.libs.ws.ahc.AhcWSClient$.apply(AhcWSClient.scala:68)
....
The reason is because play.shaded.ahc.org.asynchttpclient.config.AsyncHttpClientConfigHelper.Config#parsePropertiesFile() finds ahc-default.properties in the original jar, not in the shaded one. And because of this play.shaded.ahc.org.asynchttpclient.maxRedirects property cannot be found.
This issue is related to #87
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in AsyncHttpClientConfigHelper.Config#parsePropertiesFile(), where the issue reports that ahc-default.properties is found through the thread context class loader. Reproduce with both async-http-client 2.0.31 and Play WS dependencies, then verify that the shaded resource is selected and play.shaded.ahc.org.asynchttpclient.maxRedirects is available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, scala
- Domain
- backend, networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100