… dependency injection (#4909)
Play was instantiating a new flow materializer for every test. Each one instantiated created a new actor, leading to an actor leak.
* Moving from RC3 to RC4 had quite an impact because of the many class' renamings. * It seems there is an overloading issue with `Flow.to` (see comment in `play.libs.streams.Accumulator.through`). We should report the problem to the akka team. * Had to make `play.it.http.JavaResultsHandlingSpec` and `play.it.http.ScalaResultsHandlingSpec` running sequentially because they would fail otherwise (not sure what has changed in akka-http to cause it, but I assumed it may have been caused by additional asynchronism in the impl). One thing that worries me is that some akka-streams type leak into the Play user API (for instance, see `FlowMaterializer` in `play.api.mvc.Filters`), and akka-streams is an experimental module that hence doesn't ensure backward binary compatibility across releases. I'm not sure if this is actually going to be an issue, but I think we should keep it in mind.
1. Code documentation was also updated to remove mentions about F.Option and subclasses of it. 2. The Some class, which was a subclass of F.Option did not complain about null values. Because of that, Optional.ofNullable was used to guarantee the same behavior. 3. Some other small changes were made to cleanup the code, following the boy scout rule defined in contribution guidelines.
As explained in d24c79d, we are embracing Java8 functional interfaces. This commit makes the following changes: * `F.Function0` -> `java.util.function.Supplier` * `F.Function1` -> `java.util.function.Function` * `F.Function2` -> `java.util.function.BiFunction` The change is source compatible if the lambda's body passed to either of the former `F.Function` types does not throw a checked exception. Otherwise, users will need to update their code to catch the exception and provide the necessary logic to deal with it. There is however an important change affecting source compatibility, as several of the methods in `F.Promise` used to throw (Throwable), while they don't now ( Ref #4691). There is one additional function type that has no corresponding in the Java8 library: `F.Function3`. This type is currently only used in the `RoutingDsl`, so I initially thought we could remove it. However, it's tricky to remove functionality, so I decided to leave it alone for the moment, as we can always revisit this in the future.
* Implemented new Accumulator abstraction, based on Sink[E, Future[A]] * Implemented subscriber to iteratee reactive streams conversion * Changed EssentialAction and BodyParser APIs to use Accumulator * Left most of everything else untouched, just used conversions to to convert to/from iteratees * Fixed a race condition in Play's Netty expect 100 continue code, where Iteratee.fold was being invoked twice, which causes a problem for reactive streams.