manual adjustments before scalafmt

* fix formatting error

* reversePrepend instead of reverse_:::
  * because it is causing trouble for AvoidInfix formatting

* prepare for AvoidInfix

* fix try-catch
This commit is contained in:
Patrik Nordwall 2019-02-09 15:17:14 +01:00
parent 5c96a5f556
commit 0f40491d42
15 changed files with 29 additions and 25 deletions

View file

@ -272,11 +272,12 @@ private[akka] final class TestProbeImpl[M](name: String, system: ActorSystem[_])
val maybeMsg = receiveOne_internal(timeout) val maybeMsg = receiveOne_internal(timeout)
maybeMsg match { maybeMsg match {
case Some(message) => case Some(message) =>
val outcome = try fisher(message) catch { val outcome =
case ex: MatchError => throw new AssertionError( try fisher(message) catch {
s"Unexpected message $message while fishing for messages, " + case ex: MatchError => throw new AssertionError(
s"seen messages ${seen.reverse}, hint: $hint", ex) s"Unexpected message $message while fishing for messages, " +
} s"seen messages ${seen.reverse}, hint: $hint", ex)
}
outcome match { outcome match {
case FishingOutcome.Complete => (message :: seen).reverse case FishingOutcome.Complete => (message :: seen).reverse
case FishingOutcome.Fail(error) => assertFail(s"$error, hint: $hint") case FishingOutcome.Fail(error) => assertFail(s"$error, hint: $hint")

View file

@ -101,7 +101,7 @@ class SystemMessageListSpec extends AkkaSpec {
val fwdList = create3 :: create4 :: create5 :: ENil val fwdList = create3 :: create4 :: create5 :: ENil
val revList = create2 :: create1 :: create0 :: LNil val revList = create2 :: create1 :: create0 :: LNil
val list = revList reverse_::: fwdList val list = fwdList.reversePrepend(revList)
(list.head eq create0) should ===(true) (list.head eq create0) should ===(true)
(list.tail.head eq create1) should ===(true) (list.tail.head eq create1) should ===(true)
@ -111,9 +111,9 @@ class SystemMessageListSpec extends AkkaSpec {
(list.tail.tail.tail.tail.tail.head eq create5) should ===(true) (list.tail.tail.tail.tail.tail.head eq create5) should ===(true)
(list.tail.tail.tail.tail.tail.tail.head eq null) should ===(true) (list.tail.tail.tail.tail.tail.tail.head eq null) should ===(true)
(LNil reverse_::: ENil) == ENil should ===(true) ENil.reversePrepend(LNil) == ENil should ===(true)
((create0 :: LNil reverse_::: ENil).head eq create0) should ===(true) (ENil.reversePrepend(create0 :: LNil).head eq create0) should ===(true)
((LNil reverse_::: create0 :: ENil).head eq create0) should ===(true) ((create0 :: ENil).reversePrepend(LNil).head eq create0) should ===(true)
} }
} }

View file

@ -157,7 +157,7 @@ private[typed] class EarliestFirstSystemMessageList(val head: SystemMessage) ext
* *
* The cost of this operation is linear in the size of the list that is to be prepended. * The cost of this operation is linear in the size of the list that is to be prepended.
*/ */
final def reverse_:::(other: LatestFirstSystemMessageList): EarliestFirstSystemMessageList = { final def reversePrepend(other: LatestFirstSystemMessageList): EarliestFirstSystemMessageList = {
var remaining = other var remaining = other
var result = this var result = this
while (remaining.nonEmpty) { while (remaining.nonEmpty) {

View file

@ -323,7 +323,7 @@ private[akka] abstract class AbstractLogger extends Logger {
*/ */
private def format(t: String, arg1: Any): String = arg1 match { private def format(t: String, arg1: Any): String = arg1 match {
case a: Array[_] if !a.getClass.getComponentType.isPrimitive => formatArray(t, a: _*) case a: Array[_] if !a.getClass.getComponentType.isPrimitive => formatArray(t, a: _*)
case a: Array[_] => formatArray(t, (a map (_.asInstanceOf[AnyRef]): _*)) case a: Array[_] => formatArray(t, a.map(_.asInstanceOf[AnyRef]): _*)
case x => formatArray(t, x) case x => formatArray(t, x)
} }
private def format(t: String, arg1: Any, arg2: Any): String = formatArray(t, arg1, arg2) private def format(t: String, arg1: Any, arg2: Any): String = formatArray(t, arg1, arg2)

View file

@ -540,7 +540,7 @@ private[akka] class ActorCell(
val newState = calculateState val newState = calculateState
// As each state accepts a strict subset of another state, it is enough to unstash if we "walk up" the state // As each state accepts a strict subset of another state, it is enough to unstash if we "walk up" the state
// chain // chain
val todo = if (newState < currentState) unstashAll() reverse_::: rest else rest val todo = if (newState < currentState) rest.reversePrepend(unstashAll()) else rest
if (isTerminated) sendAllToDeadLetters(todo) if (isTerminated) sendAllToDeadLetters(todo)
else if (todo.nonEmpty) invokeAll(todo, newState) else if (todo.nonEmpty) invokeAll(todo, newState)

View file

@ -158,7 +158,7 @@ private[akka] class EarliestFirstSystemMessageList(val head: SystemMessage) exte
* *
* The cost of this operation is linear in the size of the list that is to be prepended. * The cost of this operation is linear in the size of the list that is to be prepended.
*/ */
final def reverse_:::(other: LatestFirstSystemMessageList): EarliestFirstSystemMessageList = { final def reversePrepend(other: LatestFirstSystemMessageList): EarliestFirstSystemMessageList = {
var remaining = other var remaining = other
var result = this var result = this
while (remaining.nonEmpty) { while (remaining.nonEmpty) {
@ -169,6 +169,9 @@ private[akka] class EarliestFirstSystemMessageList(val head: SystemMessage) exte
result result
} }
final def reverse_:::(other: LatestFirstSystemMessageList): EarliestFirstSystemMessageList =
reversePrepend(other)
} }
/** /**

View file

@ -1301,7 +1301,7 @@ trait LoggingAdapter {
*/ */
private def format1(t: String, arg: Any): String = arg match { private def format1(t: String, arg: Any): String = arg match {
case a: Array[_] if !a.getClass.getComponentType.isPrimitive => format(t, a: _*) case a: Array[_] if !a.getClass.getComponentType.isPrimitive => format(t, a: _*)
case a: Array[_] => format(t, (a map (_.asInstanceOf[AnyRef]): _*)) case a: Array[_] => format(t, a.map(_.asInstanceOf[AnyRef]): _*)
case x => format(t, x) case x => format(t, x)
} }
@ -1714,7 +1714,7 @@ class MarkerLoggingAdapter(
// Copy of LoggingAdapter.format1 due to binary compatibility restrictions // Copy of LoggingAdapter.format1 due to binary compatibility restrictions
private def format1(t: String, arg: Any): String = arg match { private def format1(t: String, arg: Any): String = arg match {
case a: Array[_] if !a.getClass.getComponentType.isPrimitive => format(t, a: _*) case a: Array[_] if !a.getClass.getComponentType.isPrimitive => format(t, a: _*)
case a: Array[_] => format(t, (a map (_.asInstanceOf[AnyRef]): _*)) case a: Array[_] => format(t, a.map(_.asInstanceOf[AnyRef]): _*)
case x => format(t, x) case x => format(t, x)
} }
} }

View file

@ -122,7 +122,7 @@ class DiscardStrategyPersistentActorBoundedStashingSpec
//internal stash overflow after 10 //internal stash overflow after 10
1 to (2 * capacity) foreach (persistentActor ! Cmd(_)) 1 to (2 * capacity) foreach (persistentActor ! Cmd(_))
//so, 11 to 20 discard to deadletter //so, 11 to 20 discard to deadletter
(1 + capacity) to (2 * capacity) foreach (i => expectMsg(DeadLetter(Cmd(i), testActor, persistentActor))) ((1 + capacity) to (2 * capacity)).foreach (i => expectMsg(DeadLetter(Cmd(i), testActor, persistentActor)))
//allow "a" and 1 to 10 write complete //allow "a" and 1 to 10 write complete
1 to (1 + capacity) foreach (i => SteppingInmemJournal.step(journal)) 1 to (1 + capacity) foreach (i => SteppingInmemJournal.step(journal))
@ -150,7 +150,7 @@ class ReplyToStrategyPersistentActorBoundedStashingSpec
//internal stash overflow after 10 //internal stash overflow after 10
1 to (2 * capacity) foreach (persistentActor ! Cmd(_)) 1 to (2 * capacity) foreach (persistentActor ! Cmd(_))
//so, 11 to 20 reply to with "Reject" String //so, 11 to 20 reply to with "Reject" String
(1 + capacity) to (2 * capacity) foreach (i => expectMsg("RejectToStash")) ((1 + capacity) to (2 * capacity)).foreach (i => expectMsg("RejectToStash"))
//allow "a" and 1 to 10 write complete //allow "a" and 1 to 10 write complete
1 to (1 + capacity) foreach (i => SteppingInmemJournal.step(journal)) 1 to (1 + capacity) foreach (i => SteppingInmemJournal.step(journal))

View file

@ -514,7 +514,7 @@ private[transport] class ProtocolStateActor(
stop() stop()
case Event(HandleListenerRegistered(listener), AssociatedWaitHandler(_, wrappedHandle, queue)) => case Event(HandleListenerRegistered(listener), AssociatedWaitHandler(_, wrappedHandle, queue)) =>
queue.foreach { listener notify InboundPayload(_) } queue.foreach {p => listener notify InboundPayload(p) }
stay() using ListenerReady(listener, wrappedHandle) stay() using ListenerReady(listener, wrappedHandle)
} }

View file

@ -258,7 +258,7 @@ private[netty] abstract class ServerHandler(
val remoteAddress = NettyTransport.addressFromSocketAddress(remoteSocketAddress, transport.schemeIdentifier, val remoteAddress = NettyTransport.addressFromSocketAddress(remoteSocketAddress, transport.schemeIdentifier,
transport.system.name, hostName = None, port = None).getOrElse( transport.system.name, hostName = None, port = None).getOrElse(
throw new NettyTransportException(s"Unknown inbound remote address type [${remoteSocketAddress.getClass.getName}]")) throw new NettyTransportException(s"Unknown inbound remote address type [${remoteSocketAddress.getClass.getName}]"))
init(channel, remoteSocketAddress, remoteAddress, msg) { listener notify InboundAssociation(_) } init(channel, remoteSocketAddress, remoteAddress, msg) {a => listener notify InboundAssociation(a) }
} }
} }

View file

@ -97,7 +97,7 @@ trait BindCanonicalAddressBehaviors {
implicit val sys = ActorSystem("sys", config.withFallback(commonConfig)) implicit val sys = ActorSystem("sys", config.withFallback(commonConfig))
getInternal.flatMap(_.port) should contain(getExternal.port.get) getInternal.flatMap(_.port) should contain(getExternal.port.get)
getInternal.map(_.host.get should include regex "0.0.0.0".r) // regexp dot is intentional to match IPv4 and 6 addresses getInternal.map(x => x.host.get should include regex "0.0.0.0".r) // regexp dot is intentional to match IPv4 and 6 addresses
Await.result(sys.terminate(), Duration.Inf) Await.result(sys.terminate(), Duration.Inf)
} }

View file

@ -136,7 +136,7 @@ class NettyTransportSpec extends WordSpec with Matchers with BindBehavior {
implicit val sys = ActorSystem("sys", bindConfig.withFallback(commonConfig)) implicit val sys = ActorSystem("sys", bindConfig.withFallback(commonConfig))
getInternal.flatMap(_.port) should contain(getExternal.port.get) getInternal.flatMap(_.port) should contain(getExternal.port.get)
getInternal.map(_.host.get should include regex "0.0.0.0".r) // regexp dot is intentional to match IPv4 and 6 addresses getInternal.map(x => x.host.get should include regex "0.0.0.0".r) // regexp dot is intentional to match IPv4 and 6 addresses
Await.result(sys.terminate(), Duration.Inf) Await.result(sys.terminate(), Duration.Inf)
} }

View file

@ -68,13 +68,13 @@ class DslConsistencySpec extends WordSpec with Matchers {
"Java and Scala DSLs" must { "Java and Scala DSLs" must {
("Source" -> List[Class[_]](sSourceClass, jSourceClass)) :: (("Source" -> List[Class[_]](sSourceClass, jSourceClass)) ::
("SubSource" -> List[Class[_]](sSubSourceClass, jSubSourceClass)) :: ("SubSource" -> List[Class[_]](sSubSourceClass, jSubSourceClass)) ::
("Flow" -> List[Class[_]](sFlowClass, jFlowClass)) :: ("Flow" -> List[Class[_]](sFlowClass, jFlowClass)) ::
("SubFlow" -> List[Class[_]](sSubFlowClass, jSubFlowClass)) :: ("SubFlow" -> List[Class[_]](sSubFlowClass, jSubFlowClass)) ::
("Sink" -> List[Class[_]](sSinkClass, jSinkClass)) :: ("Sink" -> List[Class[_]](sSinkClass, jSinkClass)) ::
("RunnableFlow" -> List[Class[_]](sRunnableGraphClass, jRunnableGraphClass)) :: ("RunnableFlow" -> List[Class[_]](sRunnableGraphClass, jRunnableGraphClass)) ::
Nil foreach { Nil).foreach {
case (element, classes) => case (element, classes) =>
s"provide same $element transforming operators" in { s"provide same $element transforming operators" in {

View file

@ -240,7 +240,7 @@ class SourceSpec extends StreamSpec with DefaultTimeout {
case (a, _) if a > 10000000 => throw t case (a, _) if a > 10000000 => throw t
case (a, b) => Some((b, a + b) -> a) case (a, b) => Some((b, a + b) -> a)
}.runFold(List.empty[Int]) { case (xs, x) => x :: xs }.failed) { }.runFold(List.empty[Int]) { case (xs, x) => x :: xs }.failed) {
_ should be theSameInstanceAs (t) x => (x should be).theSameInstanceAs(t)
} }
} }

View file

@ -250,7 +250,7 @@ private[akka] trait SubscriberManagement[T] extends ResizableMultiReaderRingBuff
private def unregisterSubscriptionInternal(subscription: S): Unit = { private def unregisterSubscriptionInternal(subscription: S): Unit = {
@tailrec def removeFrom(remaining: Subscriptions, result: Subscriptions = Nil): Subscriptions = @tailrec def removeFrom(remaining: Subscriptions, result: Subscriptions = Nil): Subscriptions =
remaining match { remaining match {
case head :: tail => if (head eq subscription) tail reverse_::: result else removeFrom(tail, head :: result) case head :: tail => if (head eq subscription) result.reverse_:::(tail) else removeFrom(tail, head :: result)
case _ => throw new IllegalStateException("Subscription to unregister not found") case _ => throw new IllegalStateException("Subscription to unregister not found")
} }
if (subscription.active) { if (subscription.active) {