pjfanning opened a new pull request, #1276: URL: https://github.com/apache/pekko-http/pull/1276
### Motivation `RouteAdapter.flow(system, materializer)` — the implementation behind the Java DSL `Route.flow(ActorSystem, Materializer)` — accepted a `Materializer` but only used the `ActorSystem`. The flow was built through the implicit `RouteResult.routeToFlow` conversion, and `Route.toFunction` hardcodes `SystemMaterializer(system).materializer` into the `RequestContext`, so the materializer supplied by Java users was silently discarded. Routes saw the system materializer in `extractMaterializer`, in `entity(...)` unmarshalling, and in any stream run from a directive. ### Modification - `scaladsl/server/Route.scala`: added a `private[pekko] toFunction(route, materializer)` overload holding the existing body; the public `toFunction(route)` now delegates to it with `SystemMaterializer(system).materializer`, so its behaviour is unchanged. - `javadsl/server/directives/RouteAdapter.scala`: `scalaFlow` builds its handler with that overload and does the `mapAsync(1)` itself, so the given materializer reaches the `RequestContext`. No copied code. ### Result `Route.flow(system, materializer)` runs the route with the materializer it was given. The `flow(system)` overload is unaffected — it already passed `SystemMaterializer(system).materializer` explicitly. Binary compatibility is preserved: the new method is `private[pekko]` and purely additive. ### Tests - `sbt "http-tests/testOnly org.apache.pekko.http.javadsl.server.RouteFlowMaterializerTest"` — 2 passed. New test asserts the materializer observed by `extractMaterializer` for both the explicit-materializer and system-materializer overloads. Directional: with the `RouteAdapter` change reverted, `flowUsesTheGivenMaterializer` fails with `expected: <270352276> but was: <1155460560>`. - `sbt "http/scalafmt" "http-tests/Test/javafmt" "http/mimaReportBinaryIssues"` — clean (MiMa scoped to the changed module). - `sbt headerCreateAll` — header added to the new test file. - `git diff --check` — clean. ### References None - Java DSL `Route.flow(system, materializer)` ignored its materializer argument. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
