We are using a slightly updated ForwardingBodyParser that does some additional request header manipulations, but is identical to the example otherwise.
The problem is that after upgrading from java play 2.6.11 to 2.8.19 we start to experience the following errors randomly (pretty seldom and mostly right after the application startup):
[[31merror[0m] http.Errors - Internal server error
java.util.concurrent.CompletionException: java.lang.IllegalStateException: Sink.asPublisher(fanout = false) only supports one subscriber (which is allowed, see reactive-streams specification, rule 1.11)
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.postComplete(Unknown Source)
at java.base/java.util.concurrent.CompletableFuture.completeExceptionally(Unknown Source)
at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:29)
at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:26)
at scala.concurrent.impl.Promise$Transformation.run(Promise.scala:484)
at scala.concurrent.ExecutionContext$parasitic$.execute(ExecutionContext.scala:222)
at scala.concurrent.impl.Promise$Transformation.submitWithValue(Promise.scala:429)
Caused by: java.lang.IllegalStateException: Sink.asPublisher(fanout = false) only supports one subscriber (which is allowed, see reactive-streams specification, rule 1.11)
at akka.stream.impl.ReactiveStreamsCompliance$.rejectAdditionalSubscriber(ReactiveStreamsCompliance.scala:62)
at akka.stream.impl.VirtualPublisher.rec$6(StreamLayout.scala:481)
at akka.stream.impl.VirtualPublisher.subscribe(StreamLayout.scala:486)
at play.shaded.ahc.org.asynchttpclient.netty.request.body.NettyReactiveStreamsBody.write(NettyReactiveStreamsBody.java:60)
at play.shaded.ahc.org.asynchttpclient.netty.request.NettyRequestSender.writeRequest(NettyRequestSender.java:426)
at play.shaded.ahc.org.asynchttpclient.netty.channel.NettyConnectListener.writeRequest(NettyConnectListener.java:80)
at play.shaded.ahc.org.asynchttpclient.netty.channel.NettyConnectListener.access$100(NettyConnectListener.java:37)
at play.shaded.ahc.org.asynchttpclient.netty.channel.NettyConnectListener$1.onSuccess(NettyConnectListener.java:139)
at play.shaded.ahc.org.asynchttpclient.netty.channel.NettyConnectListener$1.onSuccess(NettyConnectListener.java:129)
at play.shaded.ahc.org.asynchttpclient.netty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:24)
It seems like sometimes application subscribes twice to the Source
in the Accumulator
. I can reproduce the same issue 100% of times if I do it explicitly, but I’d love to know how it could be happening in the Play internals and how it could be resolved