akka-stream compiling on Scala 3 (#30324)

Changes:
* Private constructor for case class means private apply in Scala 3
* Logger class with Any instead of wildcard where needed
* Explicit import of internal implicit conversion import SinkToCompletionStage
* Hopefully source and binary compatible Scala 3 signature for GraphApply.create methods
* ZipLatestWith leaking private type
* Auto apply-to-lambda made explicit
* Internal async callback event class covariant
* Hub leaking private type
* Remove cycles in stream Buffer classes
* Avoid cyclic import in ResizableMultiReaderRingBuffer
* Safe cast of Subscribers
* Explicit import of internal implicit conversion SourceToCompletionStage
* Ambigous field name and method
* recover delegates using PF from javadsl not inferred, made explicit
* TcpStage completing promise with wrong type
* Collect aggregator empty value cannot be underscore with type ascription
* Some type alias shenanigans in QueueSink removed
* Explicit type on effectiveMaximumBurst in Throttle
* Override method return type not inferred in GraphInterpreter
* MutableCollectorState.accumulated getter got wrong type somehow
* TLS actor fallback case only applicable to null
* Some internal unchecked pattern matching removed
* Ok that createGraph is not present in Java API
* Separate impl per language for implicit actor system apply
This commit is contained in:
Johan Andrén 2021-07-06 18:01:41 +02:00 committed by GitHub
parent 7f3bfb1a30
commit 3a3e643e07
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 259 additions and 103 deletions

View file

@ -299,8 +299,6 @@ import akka.util.ccompat._
require(maxConcurrentPulls > 0, "Max concurrent pulls must be greater than 0")
type Requested[E] = Promise[Option[E]]
val in = Inlet[T]("queueSink.in")
override def initialAttributes = DefaultAttributes.queueSink
override val shape: SinkShape[T] = SinkShape.of(in)
@ -309,14 +307,13 @@ import akka.util.ccompat._
override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
val stageLogic = new GraphStageLogic(shape) with InHandler with SinkQueueWithCancel[T] {
type Received[E] = Try[Option[E]]
val maxBuffer = inheritedAttributes.get[InputBuffer](InputBuffer(16, 16)).max
require(maxBuffer > 0, "Buffer size must be greater than 0")
// Allocates one additional element to hold stream closed/failure indicators
val buffer: Buffer[Received[T]] = Buffer(maxBuffer + 1, inheritedAttributes)
val currentRequests: Buffer[Requested[T]] = Buffer(maxConcurrentPulls, inheritedAttributes)
val buffer: Buffer[Try[Option[T]]] = Buffer(maxBuffer + 1, inheritedAttributes)
val currentRequests: Buffer[Promise[Option[T]]] = Buffer(maxConcurrentPulls, inheritedAttributes)
override def preStart(): Unit = {
setKeepGoing(true)
@ -324,7 +321,7 @@ import akka.util.ccompat._
}
private val callback = getAsyncCallback[Output[T]] {
case QueueSink.Pull(pullPromise) =>
case QueueSink.Pull(pullPromise: Promise[Option[T]] @unchecked) =>
if (currentRequests.isFull)
pullPromise.failure(
new IllegalStateException(s"Too many concurrent pulls. Specified maximum is $maxConcurrentPulls. " +
@ -337,7 +334,7 @@ import akka.util.ccompat._
case QueueSink.Cancel => completeStage()
}
def sendDownstream(promise: Requested[T]): Unit = {
def sendDownstream(promise: Promise[Option[T]]): Unit = {
val e = buffer.dequeue()
promise.complete(e)
e match {
@ -445,17 +442,19 @@ import akka.util.ccompat._
@InternalApi private[akka] final class MutableCollectorState[T, R](
collector: java.util.stream.Collector[T, Any, R],
accumulator: java.util.function.BiConsumer[Any, T],
val accumulated: Any)
_accumulated: Any)
extends CollectorState[T, R] {
override def accumulated(): Any = _accumulated
override def update(elem: T): CollectorState[T, R] = {
accumulator.accept(accumulated, elem)
accumulator.accept(_accumulated, elem)
this
}
override def finish(): R = {
// only called if completed without elements
collector.finisher().apply(accumulated)
collector.finisher().apply(_accumulated)
}
}