Artery test transport blackhole only let HandshakeReq pass (#30219)

* only let HandshakeReq is blackholed
This commit is contained in:
Renato Cavalcanti 2021-06-02 08:41:39 +02:00 committed by GitHub
parent 5abc119577
commit 3dd0c4c86b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,11 +5,10 @@
package akka.remote.artery
import java.util.concurrent.atomic.AtomicReference
import scala.annotation.tailrec
import akka.actor.Address
import akka.event.Logging
import akka.remote.artery.OutboundHandshake.HandshakeReq
import akka.remote.transport.ThrottlerTransportAdapter.Direction
import akka.stream.Attributes
import akka.stream.FlowShape
@ -173,14 +172,27 @@ private[remote] class InboundTestStage(inboundContext: InboundContext, state: Sh
push(out, env)
case _ =>
// unknown, handshake not completed
if (state.anyBlackholePresent())
if (state.anyBlackholePresent()) {
env.message match {
case _: HandshakeReq =>
log.debug(
"inbound message [{}] before handshake completed, cannot check if remote is blackholed, letting through",
Logging.messageClassName(env.message))
push(out, env) // let it through
case anyOther =>
log.debug(
"dropping inbound message [{}] with UID [{}] because of blackhole",
Logging.messageClassName(anyOther),
env.originUid)
pull(in) // drop message
}
} else {
push(out, env)
}
}
}
}
// OutHandler
override def onPull(): Unit = pull(in)