playframework / playframework/play-ws

Fix AsyncCachingHandler to not block

Open
#144 0 comments 0 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

The AsyncCachingHandler is not using the Cache Future and is blocking using Await.result internally.

https://github.com/playframework/play-ws/blob/master/play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AsyncCachingHandler.scala#L153

This can be easily fixed by only calling onCompleted inside the future's completed block.

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

Open play-ahc-ws-standalone/src/main/scala/play/api/libs/ws/ahc/cache/AsyncCachingHandler.scala around line 153 and inspect how the Cache Future is handled. Verify that onCompleted is invoked from the future's completed block rather than through blocking Await.result. Done means the handler no longer blocks while waiting for the cache future.

Written by the indexing model from the issue text.

Assessment

Tech stack
scala
Domain
backend, networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.