Skip to content

Commit 3db058b

Browse files
Auto Formatmdedetrich
authored andcommitted
format source with scalafmt, apache#1408
1 parent db9aa50 commit 3db058b

File tree

1,205 files changed

+5023
-8512
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,205 files changed

+5023
-8512
lines changed

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/CapturedLogEvent.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,8 @@ object CapturedLogEvent {
8080
case _ => None
8181
}
8282

83-
def apply(level: Level, message: String): CapturedLogEvent = {
83+
def apply(level: Level, message: String): CapturedLogEvent =
8484
CapturedLogEvent(level, message, None, None)
85-
}
8685

8786
/**
8887
* Auxiliary constructor that receives Pekko's internal [[OptionVal]] as parameters and converts them to Scala's [[Option]].
@@ -93,7 +92,6 @@ object CapturedLogEvent {
9392
level: Level,
9493
message: String,
9594
errorCause: OptionVal[Throwable],
96-
logMarker: OptionVal[Marker]): CapturedLogEvent = {
95+
logMarker: OptionVal[Marker]): CapturedLogEvent =
9796
new CapturedLogEvent(level, message, toOption(errorCause), toOption(logMarker))
98-
}
9997
}

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/ActorSystemStub.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,8 @@ import pekko.util.FutureConverters._
117117

118118
override def printTree: String = "no tree for ActorSystemStub"
119119

120-
override def systemActorOf[U](behavior: Behavior[U], name: String, props: Props): ActorRef[U] = {
120+
override def systemActorOf[U](behavior: Behavior[U], name: String, props: Props): ActorRef[U] =
121121
throw new UnsupportedOperationException("ActorSystemStub cannot create system actors")
122-
}
123122

124123
override def registerExtension[T <: Extension](ext: ExtensionId[T]): T =
125124
throw new UnsupportedOperationException("ActorSystemStub cannot register extensions")

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/BehaviorTestKitImpl.scala

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,12 @@ private[pekko] final class BehaviorTestKitImpl[T](
4949
private[pekko] def as[U]: BehaviorTestKitImpl[U] = this.asInstanceOf[BehaviorTestKitImpl[U]]
5050

5151
private var currentUncanonical = _initialBehavior
52-
private var current = {
52+
private var current =
5353
try {
5454
context.setCurrentActorThread()
5555
Behavior.validateAsInitial(Behavior.start(_initialBehavior, context))
56-
} finally {
56+
} finally
5757
context.clearCurrentActorThread()
58-
}
59-
}
6058

6159
// execute any future tasks scheduled in Actor's constructor
6260
runAllTasks()
@@ -92,24 +90,22 @@ private[pekko] final class BehaviorTestKitImpl[T](
9290

9391
def getAllEffects(): util.List[Effect] = retrieveAllEffects().asJava
9492

95-
override def expectEffect(expectedEffect: Effect): Unit = {
93+
override def expectEffect(expectedEffect: Effect): Unit =
9694
context.effectQueue.poll() match {
9795
case null => assert(expectedEffect == NoEffects, s"expected: $expectedEffect but no effects were recorded")
9896
case effect => assert(expectedEffect == effect, s"expected: $expectedEffect but found $effect")
9997
}
100-
}
10198

102-
def expectEffectClass[E <: Effect](effectClass: Class[E]): E = {
99+
def expectEffectClass[E <: Effect](effectClass: Class[E]): E =
103100
context.effectQueue.poll() match {
104101
case null if effectClass.isAssignableFrom(NoEffects.getClass) => effectClass.cast(NoEffects)
105102
case null =>
106103
throw new AssertionError(s"expected: effect type ${effectClass.getName} but no effects were recorded")
107104
case effect if effectClass.isAssignableFrom(effect.getClass) => effect.asInstanceOf[E]
108105
case other => throw new AssertionError(s"expected: effect class ${effectClass.getName} but found $other")
109106
}
110-
}
111107

112-
def expectEffectPF[R](f: PartialFunction[Effect, R]): R = {
108+
def expectEffectPF[R](f: PartialFunction[Effect, R]): R =
113109
context.effectQueue.poll() match {
114110
case null if f.isDefinedAt(NoEffects) =>
115111
f.apply(NoEffects)
@@ -118,7 +114,6 @@ private[pekko] final class BehaviorTestKitImpl[T](
118114
case other =>
119115
throw new AssertionError(s"expected matching effect but got: $other")
120116
}
121-
}
122117

123118
def expectEffectType[E <: Effect](implicit classTag: ClassTag[E]): E =
124119
expectEffectClass(classTag.runtimeClass.asInstanceOf[Class[E]])
@@ -136,14 +131,13 @@ private[pekko] final class BehaviorTestKitImpl[T](
136131
throw e
137132
}
138133

139-
private def runAllTasks(): Unit = {
134+
private def runAllTasks(): Unit =
140135
context.executionContext match {
141136
case controlled: ControlledExecutor => controlled.runAll()
142137
case _ =>
143138
}
144-
}
145139

146-
override def run(message: T): Unit = {
140+
override def run(message: T): Unit =
147141
try {
148142
context.setCurrentActorThread()
149143
try {
@@ -153,25 +147,21 @@ private[pekko] final class BehaviorTestKitImpl[T](
153147
// notice we pass current and not intercepted, this way Behaviors.same will be resolved to current which will be intercepted again on the next message
154148
// otherwise we would have risked intercepting an already intercepted behavior (or would have had to explicitly check if the current behavior is already intercepted by us)
155149
current = Behavior.canonicalize(currentUncanonical, current, context)
156-
} finally {
150+
} finally
157151
context.clearCurrentActorThread()
158-
}
159152
runAllTasks()
160153
} catch handleException
161-
}
162154

163155
override def runOne(): Unit = run(selfInbox().receiveMessage())
164156

165-
override def signal(signal: Signal): Unit = {
157+
override def signal(signal: Signal): Unit =
166158
try {
167159
context.setCurrentActorThread()
168160
currentUncanonical = Behavior.interpretSignal(current, context, signal)
169161
current = Behavior.canonicalize(currentUncanonical, current, context)
170162
} catch handleException
171-
finally {
163+
finally
172164
context.clearCurrentActorThread()
173-
}
174-
}
175165

176166
override def hasEffects(): Boolean = !context.effectQueue.isEmpty
177167

@@ -191,7 +181,7 @@ private[pekko] object BehaviorTestKitImpl {
191181
override def aroundReceive(
192182
ctx: TypedActorContext[Any],
193183
msg: Any,
194-
target: BehaviorInterceptor.ReceiveTarget[Any]): Behavior[Any] = {
184+
target: BehaviorInterceptor.ReceiveTarget[Any]): Behavior[Any] =
195185
msg match {
196186
case AdaptWithRegisteredMessageAdapter(msgToAdapt) =>
197187
val fn = ctx
@@ -206,7 +196,6 @@ private[pekko] object BehaviorTestKitImpl {
206196
target.apply(ctx, adaptedMsg)
207197
case t => target.apply(ctx, t)
208198
}
209-
}
210199

211200
def inteceptBehaviour[T](behavior: Behavior[T], ctx: TypedActorContext[T]): Behavior[T] =
212201
Behavior

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/CapturingAppender.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,8 @@ import pekko.annotation.InternalApi
8484
import pekko.util.ccompat.JavaConverters._
8585
val logbackLogger = getLogbackLogger(classOf[CapturingAppender].getName + "Delegate")
8686
val appenders = logbackLogger.iteratorForAppenders().asScala.filterNot(_ == this).toList
87-
for (event <- buffer; appender <- appenders) {
87+
for (event <- buffer; appender <- appenders)
8888
appender.doAppend(event)
89-
}
9089
clear()
9190
}
9291

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/ControlledExecutor.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,9 @@ private[pekko] final class ControlledExecutor extends ExecutionContextExecutor {
3232

3333
def runAll(): Unit = while (!tasks.isEmpty()) runOne()
3434

35-
def execute(task: Runnable): Unit = {
35+
def execute(task: Runnable): Unit =
3636
tasks.add(task)
37-
}
3837

39-
def reportFailure(cause: Throwable): Unit = {
38+
def reportFailure(cause: Throwable): Unit =
4039
cause.printStackTrace()
41-
}
4240
}

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/EffectfulActorContext.scala

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ import scala.reflect.ClassTag
127127

128128
override def cancelAll(): Unit = activeTimers.foreach(cancel)
129129

130-
private def sendAction(key: Any): () => Unit = () => {
130+
private def sendAction(key: Any): () => Unit = () =>
131131
activeTimers.get(key).foreach {
132132
case Effect.TimerScheduled(_, msg, _, mode, _) =>
133133
mode match {
@@ -138,8 +138,6 @@ import scala.reflect.ClassTag
138138
self ! msg
139139
}
140140

141-
}
142-
143141
def startTimer(key: Any, msg: T, delay: FiniteDuration, mode: Effect.TimerScheduled.TimerMode) = {
144142
val effect = Effect.TimerScheduled(key, msg, delay, mode, activeTimers.keySet(key))(sendAction(key))
145143
activeTimers += (key -> effect)

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/LogbackUtil.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import scala.annotation.tailrec
3030
getLogbackLoggerInternal(loggerName, 50)
3131

3232
@tailrec
33-
private def getLogbackLoggerInternal(loggerName: String, count: Int): ch.qos.logback.classic.Logger = {
33+
private def getLogbackLoggerInternal(loggerName: String, count: Int): ch.qos.logback.classic.Logger =
3434
LoggerFactory.getLogger(loggerNameOrRoot(loggerName)) match {
3535
case logger: ch.qos.logback.classic.Logger => logger
3636
case _: org.slf4j.helpers.SubstituteLogger if count > 0 =>
@@ -43,9 +43,8 @@ import scala.annotation.tailrec
4343
throw new IllegalArgumentException(
4444
s"Requires Logback logger for [$loggerName], it was a [${other.getClass.getName}]")
4545
}
46-
}
4746

48-
def convertLevel(level: ch.qos.logback.classic.Level): Level = {
47+
def convertLevel(level: ch.qos.logback.classic.Level): Level =
4948
level.levelInt match {
5049
case ch.qos.logback.classic.Level.TRACE_INT => Level.TRACE
5150
case ch.qos.logback.classic.Level.DEBUG_INT => Level.DEBUG
@@ -55,5 +54,4 @@ import scala.annotation.tailrec
5554
case _ =>
5655
throw new IllegalArgumentException("Level " + level.levelStr + ", " + level.levelInt + " is unknown.")
5756
}
58-
}
5957
}

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/LoggingTestKitImpl.scala

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -58,42 +58,39 @@ import pekko.testkit.TestKit
5858
@volatile // JMM does not guarantee visibility for non-final fields
5959
private var todo = occurrences
6060

61-
def matches(event: LoggingEvent): Boolean = {
61+
def matches(event: LoggingEvent): Boolean =
6262
logLevel.forall(_ == event.level) &&
63-
source.forall(_ == sourceOrEmpty(event)) &&
64-
messageContains.forall(messageOrEmpty(event).contains) &&
65-
messageRegex.forall(_.findFirstIn(messageOrEmpty(event)).isDefined) &&
66-
cause.forall(c => event.throwable.isDefined && c.isInstance(event.throwable.get)) &&
67-
mdc.forall { case (key, value) => event.mdc.contains(key) && event.mdc(key) == value } &&
68-
custom.forall(f => f(event))
63+
source.forall(_ == sourceOrEmpty(event)) &&
64+
messageContains.forall(messageOrEmpty(event).contains) &&
65+
messageRegex.forall(_.findFirstIn(messageOrEmpty(event)).isDefined) &&
66+
cause.forall(c => event.throwable.isDefined && c.isInstance(event.throwable.get)) &&
67+
mdc.forall { case (key, value) => event.mdc.contains(key) && event.mdc(key) == value } &&
68+
custom.forall(f => f(event))
6969

7070
// loggerName is handled when installing the filter, in `expect`
71-
}
7271

7372
private def messageOrEmpty(event: LoggingEvent): String =
7473
if (event.message == null) "" else event.message
7574

7675
private def sourceOrEmpty(event: LoggingEvent): String =
7776
event.mdc.getOrElse("pekkoSource", "")
7877

79-
def apply(event: LoggingEvent): Boolean = {
78+
def apply(event: LoggingEvent): Boolean =
8079
if (matches(event)) {
8180
if (todo != Int.MaxValue) todo -= 1
8281
true
8382
} else false
84-
}
8583

8684
private def awaitDone(max: Duration): Boolean = {
8785
if (todo != Int.MaxValue && todo > 0) TestKit.awaitCond(todo <= 0, max, noThrow = true)
8886
todo == Int.MaxValue || todo == 0
8987
}
9088

91-
private def awaitNoExcess(max: Duration): Boolean = {
89+
private def awaitNoExcess(max: Duration): Boolean =
9290
if (todo == 0)
9391
!TestKit.awaitCond(todo < 0, max, noThrow = true)
9492
else
9593
todo > 0
96-
}
9794

9895
override def expect[T](code: => T)(implicit system: ActorSystem[_]): T = {
9996
val effectiveLoggerName = loggerName.getOrElse("")
@@ -127,11 +124,10 @@ import pekko.testkit.TestKit
127124
override def intercept[T](code: => T)(implicit system: ActorSystem[_]): T =
128125
expect(code)(system)
129126

130-
private def checkLogback(system: ActorSystem[_]): Unit = {
127+
private def checkLogback(system: ActorSystem[_]): Unit =
131128
if (!system.dynamicAccess.classIsOnClasspath("ch.qos.logback.classic.spi.ILoggingEvent")) {
132129
throw new IllegalStateException("LoggingEventFilter requires logback-classic dependency in classpath.")
133130
}
134-
}
135131

136132
override def withOccurrences(newOccurrences: Int): LoggingTestKitImpl =
137133
copy(occurrences = newOccurrences)

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/StubbedActorContext.scala

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,11 @@ private[pekko] final class FunctionRef[-T](override val path: ActorPath, send: (
7474
currentBehaviorProvider: () => Behavior[T])
7575
extends ActorContextImpl[T] {
7676

77-
def this(system: ActorSystemStub, name: String, currentBehaviorProvider: () => Behavior[T]) = {
77+
def this(system: ActorSystemStub, name: String, currentBehaviorProvider: () => Behavior[T]) =
7878
this(system, (system.path / name).withUid(rnd().nextInt()), currentBehaviorProvider)
79-
}
8079

81-
def this(name: String, currentBehaviorProvider: () => Behavior[T]) = {
80+
def this(name: String, currentBehaviorProvider: () => Behavior[T]) =
8281
this(new ActorSystemStub("StubbedActorContext"), name, currentBehaviorProvider)
83-
}
8482

8583
/**
8684
* INTERNAL API
@@ -141,21 +139,16 @@ private[pekko] final class FunctionRef[-T](override val path: ActorPath, send: (
141139
_children -= child.path.name
142140
}
143141
}
144-
override def watch[U](other: ActorRef[U]): Unit = {
142+
override def watch[U](other: ActorRef[U]): Unit =
145143
checkCurrentActorThread()
146-
}
147-
override def watchWith[U](other: ActorRef[U], message: T): Unit = {
144+
override def watchWith[U](other: ActorRef[U], message: T): Unit =
148145
checkCurrentActorThread()
149-
}
150-
override def unwatch[U](other: ActorRef[U]): Unit = {
146+
override def unwatch[U](other: ActorRef[U]): Unit =
151147
checkCurrentActorThread()
152-
}
153-
override def setReceiveTimeout(d: FiniteDuration, message: T): Unit = {
148+
override def setReceiveTimeout(d: FiniteDuration, message: T): Unit =
154149
checkCurrentActorThread()
155-
}
156-
override def cancelReceiveTimeout(): Unit = {
150+
override def cancelReceiveTimeout(): Unit =
157151
checkCurrentActorThread()
158-
}
159152

160153
override def scheduleOnce[U](delay: FiniteDuration, target: ActorRef[U], message: U): classic.Cancellable =
161154
new classic.Cancellable {
@@ -223,15 +216,13 @@ private[pekko] final class FunctionRef[-T](override val path: ActorPath, send: (
223216
logger
224217
}
225218

226-
override def setLoggerName(name: String): Unit = {
219+
override def setLoggerName(name: String): Unit =
227220
// nop as we don't track logger
228221
checkCurrentActorThread()
229-
}
230222

231-
override def setLoggerName(clazz: Class[_]): Unit = {
223+
override def setLoggerName(clazz: Class[_]): Unit =
232224
// nop as we don't track logger
233225
checkCurrentActorThread()
234-
}
235226

236227
/**
237228
* The log entries logged through context.log.{debug, info, warn, error} are captured and can be inspected through
@@ -243,15 +234,13 @@ private[pekko] final class FunctionRef[-T](override val path: ActorPath, send: (
243234
.iterator()
244235
.asScala
245236
.map { evt =>
246-
{
247-
val marker: Option[Marker] = Option(evt.getMarkers).flatMap(_.asScala.headOption)
248-
CapturedLogEvent(
249-
level = evt.getLevel,
250-
message = MessageFormatter.arrayFormat(evt.getMessage, evt.getArgumentArray).getMessage,
251-
cause = Option(evt.getThrowable),
252-
marker = marker)
237+
val marker: Option[Marker] = Option(evt.getMarkers).flatMap(_.asScala.headOption)
238+
CapturedLogEvent(
239+
level = evt.getLevel,
240+
message = MessageFormatter.arrayFormat(evt.getMessage, evt.getArgumentArray).getMessage,
241+
cause = Option(evt.getThrowable),
242+
marker = marker)
253243

254-
}
255244
}
256245
.toList
257246
}

actor-testkit-typed/src/main/scala/org/apache/pekko/actor/testkit/typed/internal/TestAppender.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,13 @@ import pekko.annotation.InternalApi
103103
filter(loggingEvent)
104104
}
105105

106-
private def filter(event: LoggingEvent): Boolean = {
106+
private def filter(event: LoggingEvent): Boolean =
107107
filters.exists(f =>
108-
try {
108+
try
109109
f.apply(event)
110-
} catch {
110+
catch {
111111
case _: Exception => false
112112
})
113-
}
114113

115114
def addTestFilter(filter: LoggingTestKitImpl): Unit = synchronized {
116115
filters ::= filter

0 commit comments

Comments
 (0)