playframework / playframework/play-ws

Wrong 'ahc-default.properties' resource file loaded when there's a non-shaded version of asynchttpclient in the class path.

Open
#177 5 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:backlog
Dominant language
Scala
Stars
224
Forks
92
Avg merge
1d 19h
Merged PRs (30d)
28

Description

Are you looking for help?
Play WS Version (2.5.x / etc)

2.6.2

API (Scala / Java / Neither / Both)

Both

Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)

Windows 10

JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)

java version "1.8.0_77"
Java(TM) SE Runtime Environment (build 1.8.0_77-b03)
Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode)

Library Dependencies
Expected Behavior

When there is a non-shaded version of asynchttpclient in the class path, depending on the order of jars in the classpath, the non-shaded version of the ahc-default.properties file can get loaded. This in turn makes config queries fail with using the prefix 'play.shaded.ahc'. I would expect the shaded library to specifically load the shaded properties files by renaming the shaded property files.

Actual Behavior

NumberFomatException occurs when trying to instantiate the AsyncHttpClientProvider class when launching a play application.

Caused by: 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.AsyncHttpClientProvider.<init>(AhcWSModule.scala:64)
        at play.api.libs.ws.ahc.AsyncHttpClientProvider$$FastClassByGuice$$68dd0aee.newInstance(<generated>)
        at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the resource-loading path in the shaded AsyncHttpClient classes named in the stack trace, then trace how AhcConfig.scala and AsyncHttpClientProvider use those defaults. Reproduce the failure with shaded and non-shaded client jars in different classpath orders. Done means the shaded client consistently loads its own properties and AsyncHttpClientProvider starts without the NumberFormatException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, scala
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.