Advertisement
Guest User

Untitled

a guest
Mar 24th, 2018
358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 274.56 KB | None | 0 0
  1. diff --git a/akka-remote/src/main/scala/akka/remote/AckedDelivery.scala b/akka-remote/src/main/scala/akka/remote/AckedDelivery.scala
  2. index ec6b281058..32a523979b 100644
  3. --- a/akka-remote/src/main/scala/akka/remote/AckedDelivery.scala
  4. +++ b/akka-remote/src/main/scala/akka/remote/AckedDelivery.scala
  5. @@ -36,14 +36,14 @@ final case class SeqNo(rawValue: Long) extends Ordered[SeqNo] {
  6. */
  7. def inc: SeqNo = new SeqNo(this.rawValue + 1L)
  8.  
  9. - override def compare(that: SeqNo) = SeqNo.ord.compare(this, that)
  10. + override def compare(that: SeqNo): Int = SeqNo.ord.compare(this, that)
  11.  
  12. - override def toString = String.valueOf(rawValue)
  13. + override def toString: String = String.valueOf(rawValue)
  14. }
  15.  
  16. object HasSequenceNumber {
  17. implicit def seqOrdering[T <: HasSequenceNumber]: Ordering[T] = new Ordering[T] {
  18. - def compare(x: T, y: T) = x.seq.compare(y.seq)
  19. + def compare(x: T, y: T): Int = x.seq.compare(y.seq)
  20. }
  21. }
  22.  
  23. @@ -66,7 +66,7 @@ trait HasSequenceNumber {
  24. * @param nacks Set of sequence numbers between the last delivered one and cumulativeAck that has been not yet received.
  25. */
  26. final case class Ack(cumulativeAck: SeqNo, nacks: Set[SeqNo] = Set.empty) {
  27. - override def toString = s"ACK[$cumulativeAck, ${nacks.mkString("{", ", ", "}")}]"
  28. + override def toString: String = s"ACK[$cumulativeAck, ${nacks.mkString("{", ", ", "}")}]"
  29. }
  30.  
  31. class ResendBufferCapacityReachedException(c: Int)
  32. @@ -125,7 +125,7 @@ final case class AckedSendBuffer[T <: HasSequenceNumber](
  33. this.copy(nonAcked = this.nonAcked :+ msg, maxSeq = msg.seq)
  34. }
  35.  
  36. - override def toString = s"[$maxSeq ${nonAcked.map(_.seq).mkString("{", ", ", "}")}]"
  37. + override def toString: String = s"[$maxSeq ${nonAcked.map(_.seq).mkString("{", ", ", "}")}]"
  38. }
  39.  
  40. /**
  41. @@ -201,5 +201,5 @@ final case class AckedReceiveBuffer[T <: HasSequenceNumber](
  42. buf = (this.buf union that.buf).filter { _.seq > mergedLastDelivered })
  43. }
  44.  
  45. - override def toString = buf.map { _.seq }.mkString("[", ", ", "]")
  46. + override def toString: String = buf.map { _.seq }.mkString("[", ", ", "]")
  47. }
  48. diff --git a/akka-remote/src/main/scala/akka/remote/AddressUidExtension.scala b/akka-remote/src/main/scala/akka/remote/AddressUidExtension.scala
  49. index a87bcb584c..a42042f59b 100644
  50. --- a/akka-remote/src/main/scala/akka/remote/AddressUidExtension.scala
  51. +++ b/akka-remote/src/main/scala/akka/remote/AddressUidExtension.scala
  52. @@ -21,7 +21,7 @@ import akka.actor.ExtensionIdProvider
  53. object AddressUidExtension extends ExtensionId[AddressUidExtension] with ExtensionIdProvider {
  54. override def get(system: ActorSystem): AddressUidExtension = super.get(system)
  55.  
  56. - override def lookup = AddressUidExtension
  57. + override def lookup: AddressUidExtension.type = AddressUidExtension
  58.  
  59. override def createExtension(system: ExtendedActorSystem): AddressUidExtension = new AddressUidExtension(system)
  60.  
  61. diff --git a/akka-remote/src/main/scala/akka/remote/BoundAddressesExtension.scala b/akka-remote/src/main/scala/akka/remote/BoundAddressesExtension.scala
  62. index a572ae8cc6..17d8aa2a27 100644
  63. --- a/akka-remote/src/main/scala/akka/remote/BoundAddressesExtension.scala
  64. +++ b/akka-remote/src/main/scala/akka/remote/BoundAddressesExtension.scala
  65. @@ -17,7 +17,7 @@ import akka.remote.artery.ArteryTransport
  66. object BoundAddressesExtension extends ExtensionId[BoundAddressesExtension] with ExtensionIdProvider {
  67. override def get(system: ActorSystem): BoundAddressesExtension = super.get(system)
  68.  
  69. - override def lookup = BoundAddressesExtension
  70. + override def lookup: BoundAddressesExtension.type = BoundAddressesExtension
  71.  
  72. override def createExtension(system: ExtendedActorSystem): BoundAddressesExtension =
  73. new BoundAddressesExtension(system)
  74. diff --git a/akka-remote/src/main/scala/akka/remote/Endpoint.scala b/akka-remote/src/main/scala/akka/remote/Endpoint.scala
  75. index 3c23996ee3..8d41fd615b 100644
  76. --- a/akka-remote/src/main/scala/akka/remote/Endpoint.scala
  77. +++ b/akka-remote/src/main/scala/akka/remote/Endpoint.scala
  78. @@ -31,6 +31,8 @@ import java.util.concurrent.locks.LockSupport
  79. import scala.concurrent.Future
  80. import akka.util.OptionVal
  81. import akka.util.OptionVal
  82. +import akka.dispatch.MessageDispatcher
  83. +import java.util.LinkedList
  84.  
  85. /**
  86. * INTERNAL API
  87. @@ -215,7 +217,7 @@ private[remote] class ReliableDeliverySupervisor(
  88. val autoResendTimer = context.system.scheduler.schedule(
  89. settings.SysResendTimeout, settings.SysResendTimeout, self, AttemptSysMsgRedelivery)
  90.  
  91. - override val supervisorStrategy = OneForOneStrategy(loggingEnabled = false) {
  92. + override val supervisorStrategy: OneForOneStrategy = OneForOneStrategy(loggingEnabled = false) {
  93. case e @ (_: AssociationProblem) ⇒ Escalate
  94. case NonFatal(e) ⇒
  95. val causedBy = if (e.getCause == null) "" else s"Caused by: [${e.getCause.getMessage}]"
  96. @@ -460,7 +462,7 @@ private[remote] abstract class EndpointActor(
  97.  
  98. def inbound: Boolean
  99.  
  100. - val eventPublisher = new EventPublisher(context.system, log, settings.RemoteLifecycleEventsLogLevel)
  101. + val eventPublisher: EventPublisher = new EventPublisher(context.system, log, settings.RemoteLifecycleEventsLogLevel)
  102.  
  103. def publishError(reason: Throwable, logLevel: Logging.LogLevel): Unit =
  104. tryPublish(AssociationErrorEvent(reason, localAddress, remoteAddress, inbound, logLevel))
  105. @@ -539,34 +541,34 @@ private[remote] class EndpointWriter(
  106.  
  107. private val markLog = Logging.withMarker(this)
  108. val extendedSystem: ExtendedActorSystem = context.system.asInstanceOf[ExtendedActorSystem]
  109. - val remoteMetrics = RemoteMetricsExtension(extendedSystem)
  110. - val backoffDispatcher = context.system.dispatchers.lookup("akka.remote.backoff-remote-dispatcher")
  111. + val remoteMetrics: RemoteMetrics = RemoteMetricsExtension(extendedSystem)
  112. + val backoffDispatcher: MessageDispatcher = context.system.dispatchers.lookup("akka.remote.backoff-remote-dispatcher")
  113.  
  114. var reader: Option[ActorRef] = None
  115. var handle: Option[AkkaProtocolHandle] = handleOrActive
  116. - val readerId = Iterator from 0
  117. + val readerId: Iterator[Int] = Iterator from 0
  118.  
  119. def newAckDeadline: Deadline = Deadline.now + settings.SysMsgAckTimeout
  120. var ackDeadline: Deadline = newAckDeadline
  121.  
  122. var lastAck: Option[Ack] = None
  123.  
  124. - override val supervisorStrategy = OneForOneStrategy(loggingEnabled = false) {
  125. + override val supervisorStrategy: OneForOneStrategy = OneForOneStrategy(loggingEnabled = false) {
  126. case NonFatal(e) ⇒ publishAndThrow(e, Logging.ErrorLevel)
  127. }
  128.  
  129. - val provider = RARP(extendedSystem).provider
  130. - val msgDispatch = new DefaultMessageDispatcher(extendedSystem, provider, markLog)
  131. + val provider: RemoteActorRefProvider = RARP(extendedSystem).provider
  132. + val msgDispatch: DefaultMessageDispatcher = new DefaultMessageDispatcher(extendedSystem, provider, markLog)
  133.  
  134. - val inbound = handle.isDefined
  135. + val inbound: Boolean = handle.isDefined
  136. var stopReason: DisassociateInfo = AssociationHandle.Unknown
  137.  
  138. // Use an internal buffer instead of Stash for efficiency
  139. // stash/unstashAll is slow when many messages are stashed
  140. // IMPORTANT: sender is not stored, so sender() and forward must not be used in EndpointWriter
  141. - val buffer = new java.util.LinkedList[AnyRef]
  142. - val prioBuffer = new java.util.LinkedList[Send]
  143. - var largeBufferLogTimestamp = System.nanoTime()
  144. + val buffer: LinkedList[AnyRef] = new java.util.LinkedList[AnyRef]
  145. + val prioBuffer: LinkedList[Send] = new java.util.LinkedList[Send]
  146. + var largeBufferLogTimestamp: Long = System.nanoTime()
  147.  
  148. private def publishAndThrow(reason: Throwable, logLevel: Logging.LogLevel): Nothing = {
  149. reason match {
  150. @@ -576,7 +578,7 @@ private[remote] class EndpointWriter(
  151. throw reason
  152. }
  153.  
  154. - val ackIdleTimer = {
  155. + val ackIdleTimer: Cancellable = {
  156. val interval = settings.SysMsgAckTimeout / 2
  157. context.system.scheduler.schedule(interval, interval, self, AckIdleCheckTimer)
  158. }
  159. @@ -603,7 +605,7 @@ private[remote] class EndpointWriter(
  160. eventPublisher.notifyListeners(DisassociatedEvent(localAddress, remoteAddress, inbound))
  161. }
  162.  
  163. - def receive = if (handle.isEmpty) initializing else writing
  164. + def receive: Actor.Receive = if (handle.isEmpty) initializing else writing
  165.  
  166. def initializing: Receive = {
  167. case s: Send ⇒
  168. @@ -648,7 +650,7 @@ private[remote] class EndpointWriter(
  169. }
  170.  
  171. var writeCount = 0
  172. - var maxWriteCount = MaxWriteCount
  173. + var maxWriteCount: Int = MaxWriteCount
  174. var adaptiveBackoffNanos = 1000000L // 1 ms
  175. var fullBackoff = false
  176.  
  177. @@ -941,8 +943,8 @@ private[remote] class EndpointReader(
  178.  
  179. import EndpointWriter.{ OutboundAck, StopReading, StoppedReading }
  180.  
  181. - val provider = RARP(context.system).provider
  182. - var ackedReceiveBuffer = new AckedReceiveBuffer[Message]
  183. + val provider: RemoteActorRefProvider = RARP(context.system).provider
  184. + var ackedReceiveBuffer: AckedReceiveBuffer[Message] = new AckedReceiveBuffer[Message]
  185.  
  186. override def preStart(): Unit = {
  187. receiveBuffers.get(Link(localAddress, remoteAddress)) match {
  188. diff --git a/akka-remote/src/main/scala/akka/remote/FailureDetector.scala b/akka-remote/src/main/scala/akka/remote/FailureDetector.scala
  189. index 0e22eea364..ece1071e9e 100644
  190. --- a/akka-remote/src/main/scala/akka/remote/FailureDetector.scala
  191. +++ b/akka-remote/src/main/scala/akka/remote/FailureDetector.scala
  192. @@ -39,7 +39,7 @@ object FailureDetector {
  193. // Abstract class to be able to extend it from Java
  194. abstract class Clock extends (() ⇒ Long)
  195.  
  196. - implicit val defaultClock = new Clock {
  197. - def apply() = NANOSECONDS.toMillis(System.nanoTime)
  198. + implicit val defaultClock: Clock = new Clock {
  199. + def apply(): Long = NANOSECONDS.toMillis(System.nanoTime)
  200. }
  201. }
  202. diff --git a/akka-remote/src/main/scala/akka/remote/FailureDetectorRegistry.scala b/akka-remote/src/main/scala/akka/remote/FailureDetectorRegistry.scala
  203. index 527bf62a03..3b4c282936 100644
  204. --- a/akka-remote/src/main/scala/akka/remote/FailureDetectorRegistry.scala
  205. +++ b/akka-remote/src/main/scala/akka/remote/FailureDetectorRegistry.scala
  206. @@ -84,6 +84,6 @@ private[akka] object FailureDetectorLoader {
  207. * @param config Configuration that will be passed to the implementation
  208. * @return
  209. */
  210. - def apply(fqcn: String, config: Config)(implicit ctx: ActorContext) = load(fqcn, config, ctx.system)
  211. + def apply(fqcn: String, config: Config)(implicit ctx: ActorContext): FailureDetector = load(fqcn, config, ctx.system)
  212.  
  213. }
  214. diff --git a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala
  215. index 22f28ae9e8..0d72c0ab15 100644
  216. --- a/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala
  217. +++ b/akka-remote/src/main/scala/akka/remote/RemoteActorRefProvider.scala
  218. @@ -535,7 +535,7 @@ private[akka] class RemoteActorRef private[akka] (
  219. /**
  220. * Determine if a watch/unwatch message must be handled by the remoteWatcher actor, or sent to this remote ref
  221. */
  222. - def isWatchIntercepted(watchee: ActorRef, watcher: ActorRef) =
  223. + def isWatchIntercepted(watchee: ActorRef, watcher: ActorRef): Boolean =
  224. if (watchee.path.uid == akka.actor.ActorCell.undefinedUid) {
  225. provider.log.debug("actorFor is deprecated, and watching a remote ActorRef acquired with actorFor is not reliable: [{}]", watchee.path)
  226. false // Not managed by the remote watcher, so not reliable to communication failure or remote system crash
  227. diff --git a/akka-remote/src/main/scala/akka/remote/RemoteDeploymentWatcher.scala b/akka-remote/src/main/scala/akka/remote/RemoteDeploymentWatcher.scala
  228. index f0f6de8ccb..fba1e864f6 100644
  229. --- a/akka-remote/src/main/scala/akka/remote/RemoteDeploymentWatcher.scala
  230. +++ b/akka-remote/src/main/scala/akka/remote/RemoteDeploymentWatcher.scala
  231. @@ -26,9 +26,9 @@ private[akka] object RemoteDeploymentWatcher {
  232. */
  233. private[akka] class RemoteDeploymentWatcher extends Actor with RequiresMessageQueue[UnboundedMessageQueueSemantics] {
  234. import RemoteDeploymentWatcher._
  235. - var supervisors = Map.empty[ActorRef, InternalActorRef]
  236. + var supervisors: Map[ActorRef, InternalActorRef] = Map.empty[ActorRef, InternalActorRef]
  237.  
  238. - def receive = {
  239. + def receive: PartialFunction[Any, Unit] = {
  240. case WatchRemote(a, supervisor: InternalActorRef) ⇒
  241. supervisors += (a → supervisor)
  242. context.watch(a)
  243. diff --git a/akka-remote/src/main/scala/akka/remote/RemoteMetricsExtension.scala b/akka-remote/src/main/scala/akka/remote/RemoteMetricsExtension.scala
  244. index d00eb2f41a..5361359ccb 100644
  245. --- a/akka-remote/src/main/scala/akka/remote/RemoteMetricsExtension.scala
  246. +++ b/akka-remote/src/main/scala/akka/remote/RemoteMetricsExtension.scala
  247. @@ -22,7 +22,7 @@ import akka.routing.RouterEnvelope
  248. private[akka] object RemoteMetricsExtension extends ExtensionId[RemoteMetrics] with ExtensionIdProvider {
  249. override def get(system: ActorSystem): RemoteMetrics = super.get(system)
  250.  
  251. - override def lookup = RemoteMetricsExtension
  252. + override def lookup: RemoteMetricsExtension.type = RemoteMetricsExtension
  253.  
  254. override def createExtension(system: ExtendedActorSystem): RemoteMetrics =
  255. if (system.settings.config.getString("akka.remote.log-frame-size-exceeding").toLowerCase == "off")
  256. diff --git a/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala b/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala
  257. index 701cbeadd2..fb69311ad9 100644
  258. --- a/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala
  259. +++ b/akka-remote/src/main/scala/akka/remote/RemoteSettings.scala
  260. @@ -19,7 +19,7 @@ final class RemoteSettings(val config: Config) {
  261. import config._
  262. import scala.collection.JavaConverters._
  263.  
  264. - val Artery = ArterySettings(getConfig("akka.remote.artery"))
  265. + val Artery: ArterySettings = ArterySettings(getConfig("akka.remote.artery"))
  266.  
  267. val LogReceive: Boolean = getBoolean("akka.remote.log-received-messages")
  268.  
  269. diff --git a/akka-remote/src/main/scala/akka/remote/RemoteWatcher.scala b/akka-remote/src/main/scala/akka/remote/RemoteWatcher.scala
  270. index fe90d93281..5f18ef35a4 100644
  271. --- a/akka-remote/src/main/scala/akka/remote/RemoteWatcher.scala
  272. +++ b/akka-remote/src/main/scala/akka/remote/RemoteWatcher.scala
  273. @@ -12,6 +12,7 @@ import akka.remote.artery.ArteryMessage
  274.  
  275. import scala.collection.mutable
  276. import scala.concurrent.duration._
  277. +import scala.collection.mutable.{ HashMap, MultiMap }
  278.  
  279. /**
  280. * INTERNAL API
  281. @@ -92,27 +93,27 @@ private[akka] class RemoteWatcher(
  282.  
  283. import RemoteWatcher._
  284. import context.dispatcher
  285. - def scheduler = context.system.scheduler
  286. + def scheduler: Scheduler = context.system.scheduler
  287.  
  288. val remoteProvider: RemoteActorRefProvider = RARP(context.system).provider
  289. - val artery = remoteProvider.remoteSettings.Artery.Enabled
  290. + val artery: Boolean = remoteProvider.remoteSettings.Artery.Enabled
  291.  
  292. val (heartBeatMsg, selfHeartbeatRspMsg) =
  293. if (artery) (ArteryHeartbeat, ArteryHeartbeatRsp(AddressUidExtension(context.system).longAddressUid))
  294. else (Heartbeat, HeartbeatRsp(AddressUidExtension(context.system).addressUid))
  295.  
  296. // actors that this node is watching, map of watchee -> Set(watchers)
  297. - val watching = new mutable.HashMap[InternalActorRef, mutable.Set[InternalActorRef]]() with mutable.MultiMap[InternalActorRef, InternalActorRef]
  298. + val watching: HashMap[InternalActorRef, mutable.Set[InternalActorRef]] with MultiMap[InternalActorRef, InternalActorRef] = new mutable.HashMap[InternalActorRef, mutable.Set[InternalActorRef]]() with mutable.MultiMap[InternalActorRef, InternalActorRef]
  299.  
  300. // nodes that this node is watching, i.e. expecting heartbeats from these nodes. Map of address -> Set(watchee) on this address
  301. - val watcheeByNodes = new mutable.HashMap[Address, mutable.Set[InternalActorRef]]() with mutable.MultiMap[Address, InternalActorRef]
  302. - def watchingNodes = watcheeByNodes.keySet
  303. + val watcheeByNodes: HashMap[Address, mutable.Set[InternalActorRef]] with MultiMap[Address, InternalActorRef] = new mutable.HashMap[Address, mutable.Set[InternalActorRef]]() with mutable.MultiMap[Address, InternalActorRef]
  304. + def watchingNodes: collection.Set[Address] = watcheeByNodes.keySet
  305.  
  306. var unreachable: Set[Address] = Set.empty
  307. var addressUids: Map[Address, Long] = Map.empty
  308.  
  309. - val heartbeatTask = scheduler.schedule(heartbeatInterval, heartbeatInterval, self, HeartbeatTick)
  310. - val failureDetectorReaperTask = scheduler.schedule(unreachableReaperInterval, unreachableReaperInterval,
  311. + val heartbeatTask: Cancellable = scheduler.schedule(heartbeatInterval, heartbeatInterval, self, HeartbeatTick)
  312. + val failureDetectorReaperTask: Cancellable = scheduler.schedule(unreachableReaperInterval, unreachableReaperInterval,
  313. self, ReapUnreachableTick)
  314.  
  315. override def postStop(): Unit = {
  316. @@ -121,7 +122,7 @@ private[akka] class RemoteWatcher(
  317. failureDetectorReaperTask.cancel()
  318. }
  319.  
  320. - def receive = {
  321. + def receive: PartialFunction[Any, Unit] = {
  322. case HeartbeatTick ⇒ sendHeartbeat()
  323. case Heartbeat | ArteryHeartbeat ⇒ receiveHeartbeat()
  324. case HeartbeatRsp(uid) ⇒ receiveHeartbeatRsp(uid.toLong)
  325. diff --git a/akka-remote/src/main/scala/akka/remote/Remoting.scala b/akka-remote/src/main/scala/akka/remote/Remoting.scala
  326. index 17d01b6f9b..1b7b9ba5be 100644
  327. --- a/akka-remote/src/main/scala/akka/remote/Remoting.scala
  328. +++ b/akka-remote/src/main/scala/akka/remote/Remoting.scala
  329. @@ -46,9 +46,9 @@ private[akka] final case class RARP(provider: RemoteActorRefProvider) extends Ex
  330. */
  331. private[akka] object RARP extends ExtensionId[RARP] with ExtensionIdProvider {
  332.  
  333. - override def lookup() = RARP
  334. + override def lookup(): RARP.type = RARP
  335.  
  336. - override def createExtension(system: ExtendedActorSystem) = RARP(system.provider.asInstanceOf[RemoteActorRefProvider])
  337. + override def createExtension(system: ExtendedActorSystem): RARP = RARP(system.provider.asInstanceOf[RemoteActorRefProvider])
  338. }
  339.  
  340. /**
  341. @@ -104,11 +104,11 @@ private[remote] object Remoting {
  342. final case class RegisterTransportActor(props: Props, name: String) extends NoSerializationVerificationNeeded
  343.  
  344. private[Remoting] class TransportSupervisor extends Actor with RequiresMessageQueue[UnboundedMessageQueueSemantics] {
  345. - override def supervisorStrategy = OneForOneStrategy() {
  346. + override def supervisorStrategy: OneForOneStrategy = OneForOneStrategy() {
  347. case NonFatal(e) ⇒ Restart
  348. }
  349.  
  350. - def receive = {
  351. + def receive: PartialFunction[Any, Unit] = {
  352. case RegisterTransportActor(props, name) ⇒
  353. sender() ! context.actorOf(
  354. RARP(context.system).configureDispatcher(props.withDeploy(Deploy.local)),
  355. @@ -134,14 +134,14 @@ private[remote] class Remoting(_system: ExtendedActorSystem, _provider: RemoteAc
  356.  
  357. import provider.remoteSettings._
  358.  
  359. - val transportSupervisor = system.systemActorOf(
  360. + val transportSupervisor: ActorRef = system.systemActorOf(
  361. configureDispatcher(Props[TransportSupervisor]),
  362. "transports")
  363.  
  364. override def localAddressForRemote(remote: Address): Address = Remoting.localAddressForRemote(transportMapping, remote)
  365.  
  366. val log: LoggingAdapter = Logging(system.eventStream, getClass.getName)
  367. - val eventPublisher = new EventPublisher(system, log, RemoteLifecycleEventsLogLevel)
  368. + val eventPublisher: EventPublisher = new EventPublisher(system, log, RemoteLifecycleEventsLogLevel)
  369.  
  370. private def notifyError(msg: String, cause: Throwable): Unit =
  371. eventPublisher.notifyListeners(RemotingErrorEvent(new RemoteTransportException(msg, cause)))
  372. @@ -262,11 +262,11 @@ private[remote] object EndpointManager {
  373. case object ShutdownAndFlush extends RemotingCommand
  374. final case class Send(message: Any, senderOption: OptionVal[ActorRef], recipient: RemoteActorRef, seqOpt: Option[SeqNo] = None)
  375. extends RemotingCommand with HasSequenceNumber {
  376. - override def toString = s"Remote message $senderOption -> $recipient"
  377. + override def toString: String = s"Remote message $senderOption -> $recipient"
  378.  
  379. // This MUST throw an exception to indicate that we attempted to put a nonsequenced message in one of the
  380. // acknowledged delivery buffers
  381. - def seq = seqOpt.get
  382. + def seq: SeqNo = seqOpt.get
  383. }
  384. final case class Quarantine(remoteAddress: Address, uid: Option[Int]) extends RemotingCommand
  385. final case class ManagementCommand(cmd: Any) extends RemotingCommand
  386. @@ -445,15 +445,15 @@ private[remote] class EndpointManager(conf: Config, log: LoggingAdapter) extends
  387. import EndpointManager._
  388. import context.dispatcher
  389.  
  390. - val settings = new RemoteSettings(conf)
  391. - val extendedSystem = context.system.asInstanceOf[ExtendedActorSystem]
  392. + val settings: RemoteSettings = new RemoteSettings(conf)
  393. + val extendedSystem: ExtendedActorSystem = context.system.asInstanceOf[ExtendedActorSystem]
  394. val endpointId: Iterator[Int] = Iterator from 0
  395.  
  396. - val eventPublisher = new EventPublisher(context.system, log, settings.RemoteLifecycleEventsLogLevel)
  397. + val eventPublisher: EventPublisher = new EventPublisher(context.system, log, settings.RemoteLifecycleEventsLogLevel)
  398.  
  399. // Mapping between addresses and endpoint actors. If passive connections are turned off, incoming connections
  400. // will be not part of this map!
  401. - val endpoints = new EndpointRegistry
  402. + val endpoints: EndpointRegistry = new EndpointRegistry
  403. // Mapping between transports and the local addresses they listen to
  404. var transportMapping: Map[Address, AkkaProtocolTransport] = Map()
  405.  
  406. @@ -462,8 +462,8 @@ private[remote] class EndpointManager(conf: Config, log: LoggingAdapter) extends
  407. val pruneTimerCancellable: Cancellable =
  408. context.system.scheduler.schedule(pruneInterval, pruneInterval, self, Prune)
  409.  
  410. - var pendingReadHandoffs = Map[ActorRef, AkkaProtocolHandle]()
  411. - var stashedInbound = Map[ActorRef, Vector[InboundAssociation]]()
  412. + var pendingReadHandoffs: Map[ActorRef, AkkaProtocolHandle] = Map[ActorRef, AkkaProtocolHandle]()
  413. + var stashedInbound: Map[ActorRef, Vector[InboundAssociation]] = Map[ActorRef, Vector[InboundAssociation]]()
  414.  
  415. def handleStashedInbound(endpoint: ActorRef, writerIsIdle: Boolean) {
  416. val stashed = stashedInbound.getOrElse(endpoint, Vector.empty)
  417. @@ -479,7 +479,7 @@ private[remote] class EndpointManager(conf: Config, log: LoggingAdapter) extends
  418. case None ⇒ body
  419. }
  420.  
  421. - override val supervisorStrategy = {
  422. + override val supervisorStrategy: OneForOneStrategy = {
  423. def hopeless(e: HopelessAssociation): SupervisorStrategy.Directive = e match {
  424. case HopelessAssociation(localAddress, remoteAddress, Some(uid), reason) ⇒
  425. log.error(reason, "Association to [{}] with UID [{}] irrecoverably failed. Quarantining address.",
  426. @@ -548,9 +548,9 @@ private[remote] class EndpointManager(conf: Config, log: LoggingAdapter) extends
  427. }
  428.  
  429. // Structure for saving reliable delivery state across restarts of Endpoints
  430. - val receiveBuffers = new ConcurrentHashMap[Link, ResendState]()
  431. + val receiveBuffers: ConcurrentHashMap[Link, ResendState] = new ConcurrentHashMap[Link, ResendState]()
  432.  
  433. - def receive = {
  434. + def receive: PartialFunction[Any, Unit] = {
  435. case Listen(addressesPromise) ⇒
  436. listens map { ListensResult(addressesPromise, _) } recover {
  437. case NonFatal(e) ⇒ ListensFailure(addressesPromise, e)
  438. diff --git a/akka-remote/src/main/scala/akka/remote/RemotingLifecycleEvent.scala b/akka-remote/src/main/scala/akka/remote/RemotingLifecycleEvent.scala
  439. index cbfe7f6ec2..c0e9a80663 100644
  440. --- a/akka-remote/src/main/scala/akka/remote/RemotingLifecycleEvent.scala
  441. +++ b/akka-remote/src/main/scala/akka/remote/RemotingLifecycleEvent.scala
  442. @@ -85,7 +85,7 @@ final case class RemotingErrorEvent(cause: Throwable) extends RemotingLifecycleE
  443. object QuarantinedEvent extends AbstractFunction2[Address, Int, QuarantinedEvent] {
  444.  
  445. @deprecated("Use long uid apply", "2.4.x")
  446. - def apply(address: Address, uid: Int) = new QuarantinedEvent(address, uid)
  447. + def apply(address: Address, uid: Int): QuarantinedEvent = new QuarantinedEvent(address, uid)
  448. }
  449.  
  450. @SerialVersionUID(1L)
  451. @@ -106,7 +106,7 @@ final case class QuarantinedEvent(address: Address, longUid: Long) extends Remot
  452. def uid: Int = longUid.toInt
  453.  
  454. @deprecated("Use long uid copy method", "2.4.x")
  455. - def copy(address: Address = address, uid: Int = uid) = new QuarantinedEvent(address, uid)
  456. + def copy(address: Address = address, uid: Int = uid): QuarantinedEvent = new QuarantinedEvent(address, uid)
  457. }
  458.  
  459. @SerialVersionUID(1L)
  460. diff --git a/akka-remote/src/main/scala/akka/remote/UniqueAddress.scala b/akka-remote/src/main/scala/akka/remote/UniqueAddress.scala
  461. index 22164cd87b..0824a5de44 100644
  462. --- a/akka-remote/src/main/scala/akka/remote/UniqueAddress.scala
  463. +++ b/akka-remote/src/main/scala/akka/remote/UniqueAddress.scala
  464. @@ -7,7 +7,7 @@ import akka.actor.Address
  465.  
  466. @SerialVersionUID(1L)
  467. final case class UniqueAddress(address: Address, uid: Long) extends Ordered[UniqueAddress] {
  468. - override def hashCode = java.lang.Long.hashCode(uid)
  469. + override def hashCode: Int = java.lang.Long.hashCode(uid)
  470.  
  471. def compare(that: UniqueAddress): Int = {
  472. val result = Address.addressOrdering.compare(this.address, that.address)
  473. diff --git a/akka-remote/src/main/scala/akka/remote/artery/AeronSink.scala b/akka-remote/src/main/scala/akka/remote/artery/AeronSink.scala
  474. index 3c71a516f2..d75250d41a 100644
  475. --- a/akka-remote/src/main/scala/akka/remote/artery/AeronSink.scala
  476. +++ b/akka-remote/src/main/scala/akka/remote/artery/AeronSink.scala
  477. @@ -42,7 +42,7 @@ private[remote] object AeronSink {
  478. private final class OfferTask(pub: Publication, var buffer: UnsafeBuffer, var msgSize: Int, onOfferSuccess: AsyncCallback[Unit],
  479. giveUpAfter: Duration, onGiveUp: AsyncCallback[Unit], onPublicationClosed: AsyncCallback[Unit])
  480. extends (() ⇒ Boolean) {
  481. - val giveUpAfterNanos = giveUpAfter match {
  482. + val giveUpAfterNanos: Long = giveUpAfter match {
  483. case f: FiniteDuration ⇒ f.toNanos
  484. case _ ⇒ -1L
  485. }
  486. diff --git a/akka-remote/src/main/scala/akka/remote/artery/AeronSource.scala b/akka-remote/src/main/scala/akka/remote/artery/AeronSource.scala
  487. index 8011d0f2e2..2b49ceed91 100644
  488. --- a/akka-remote/src/main/scala/akka/remote/artery/AeronSource.scala
  489. +++ b/akka-remote/src/main/scala/akka/remote/artery/AeronSource.scala
  490. @@ -45,7 +45,7 @@ private[remote] object AeronSource {
  491.  
  492. private[remote] var messageReceived: EnvelopeBuffer = null // private to avoid scalac warning about exposing EnvelopeBuffer
  493.  
  494. - val fragmentsHandler = new Fragments(data ⇒ messageReceived = data, pool)
  495. + val fragmentsHandler: Fragments = new Fragments(data ⇒ messageReceived = data, pool)
  496. }
  497.  
  498. class Fragments(onMessage: EnvelopeBuffer ⇒ Unit, pool: EnvelopeBufferPool) extends FragmentAssembler(new FragmentHandler {
  499. @@ -84,7 +84,7 @@ private[remote] class AeronSource(
  500. val out: Outlet[EnvelopeBuffer] = Outlet("AeronSource")
  501. override val shape: SourceShape[EnvelopeBuffer] = SourceShape(out)
  502.  
  503. - override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
  504. + override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic with OutHandler with ResourceLifecycle with StageLogging, GraphStageLogic with OutHandler with ResourceLifecycle with StageLogging) = {
  505. val logic = new GraphStageLogic(shape) with OutHandler with ResourceLifecycle with StageLogging {
  506.  
  507. private val sub = aeron.addSubscription(channel, streamId)
  508. @@ -106,7 +106,7 @@ private[remote] class AeronSource(
  509. freeSessionBuffers()
  510. }
  511.  
  512. - override protected def logSource = classOf[AeronSource]
  513. + override protected def logSource: Class[AeronSource] = classOf[AeronSource]
  514.  
  515. override def preStart(): Unit = {
  516. flightRecorder.loFreq(AeronSource_Started, channelMetadata)
  517. diff --git a/akka-remote/src/main/scala/akka/remote/artery/ArterySettings.scala b/akka-remote/src/main/scala/akka/remote/artery/ArterySettings.scala
  518. index c8fbf60798..61dee5550e 100644
  519. --- a/akka-remote/src/main/scala/akka/remote/artery/ArterySettings.scala
  520. +++ b/akka-remote/src/main/scala/akka/remote/artery/ArterySettings.scala
  521. @@ -18,6 +18,7 @@ import scala.concurrent.duration._
  522. import java.net.InetAddress
  523. import java.nio.file.Path
  524. import java.util.concurrent.TimeUnit
  525. +import java.time
  526.  
  527. /** INTERNAL API */
  528. private[akka] final class ArterySettings private (config: Config) {
  529. @@ -34,7 +35,7 @@ private[akka] final class ArterySettings private (config: Config) {
  530. val Enabled: Boolean = getBoolean("enabled")
  531.  
  532. object Canonical {
  533. - val config = getConfig("canonical")
  534. + val config: Config = getConfig("canonical")
  535. import config._
  536.  
  537. val Port: Int = getInt("port").requiring(port ⇒
  538. @@ -43,7 +44,7 @@ private[akka] final class ArterySettings private (config: Config) {
  539. }
  540.  
  541. object Bind {
  542. - val config = getConfig("bind")
  543. + val config: Config = getConfig("bind")
  544. import config._
  545.  
  546. val Port: Int = getString("port") match {
  547. @@ -55,10 +56,10 @@ private[akka] final class ArterySettings private (config: Config) {
  548. case other ⇒ other
  549. }
  550.  
  551. - val BindTimeout = getDuration("bind-timeout").requiring(!_.isNegative, "bind-timeout can not be negative")
  552. + val BindTimeout: time.Duration = getDuration("bind-timeout").requiring(!_.isNegative, "bind-timeout can not be negative")
  553. }
  554.  
  555. - val LargeMessageDestinations =
  556. + val LargeMessageDestinations: WildcardIndex[NotUsed] =
  557. config.getStringList("large-message-destinations").asScala.foldLeft(WildcardIndex[NotUsed]()) { (tree, entry) ⇒
  558. val segments = entry.split('/').tail
  559. tree.insert(segments, NotUsed)
  560. @@ -72,33 +73,33 @@ private[akka] final class ArterySettings private (config: Config) {
  561. val LogAeronCounters: Boolean = config.getBoolean("log-aeron-counters")
  562.  
  563. object Advanced {
  564. - val config = getConfig("advanced")
  565. + val config: Config = getConfig("advanced")
  566. import config._
  567.  
  568. val TestMode: Boolean = getBoolean("test-mode")
  569.  
  570. - val Dispatcher = getString("use-dispatcher")
  571. - val ControlStreamDispatcher = getString("use-control-stream-dispatcher")
  572. - val MaterializerSettings = {
  573. + val Dispatcher: String = getString("use-dispatcher")
  574. + val ControlStreamDispatcher: String = getString("use-control-stream-dispatcher")
  575. + val MaterializerSettings: ActorMaterializerSettings = {
  576. val settings = ActorMaterializerSettings(config.getConfig("materializer"))
  577. if (Dispatcher.isEmpty) settings
  578. else settings.withDispatcher(Dispatcher)
  579. }
  580. - val ControlStreamMaterializerSettings = {
  581. + val ControlStreamMaterializerSettings: ActorMaterializerSettings = {
  582. val settings = ActorMaterializerSettings(config.getConfig("materializer"))
  583. if (ControlStreamDispatcher.isEmpty) settings
  584. else settings.withDispatcher(ControlStreamDispatcher)
  585. }
  586.  
  587. - val EmbeddedMediaDriver = getBoolean("embedded-media-driver")
  588. - val AeronDirectoryName = getString("aeron-dir") requiring (dir ⇒
  589. + val EmbeddedMediaDriver: Boolean = getBoolean("embedded-media-driver")
  590. + val AeronDirectoryName: String = getString("aeron-dir") requiring (dir ⇒
  591. EmbeddedMediaDriver || dir.nonEmpty, "aeron-dir must be defined when using external media driver")
  592. - val DeleteAeronDirectory = getBoolean("delete-aeron-dir")
  593. + val DeleteAeronDirectory: Boolean = getBoolean("delete-aeron-dir")
  594. val IdleCpuLevel: Int = getInt("idle-cpu-level").requiring(level ⇒
  595. 1 <= level && level <= 10, "idle-cpu-level must be between 1 and 10")
  596. - val OutboundLanes = getInt("outbound-lanes").requiring(n ⇒
  597. + val OutboundLanes: Int = getInt("outbound-lanes").requiring(n ⇒
  598. n > 0, "outbound-lanes must be greater than zero")
  599. - val InboundLanes = getInt("inbound-lanes").requiring(n ⇒
  600. + val InboundLanes: Int = getInt("inbound-lanes").requiring(n ⇒
  601. n > 0, "inbound-lanes must be greater than zero")
  602. val SysMsgBufferSize: Int = getInt("system-message-buffer-size").requiring(
  603. _ > 0, "system-message-buffer-size must be more than zero")
  604. @@ -108,44 +109,44 @@ private[akka] final class ArterySettings private (config: Config) {
  605. _ > 0, "outbound-control-queue-size must be more than zero")
  606. val OutboundLargeMessageQueueSize: Int = getInt("outbound-large-message-queue-size").requiring(
  607. _ > 0, "outbound-large-message-queue-size must be more than zero")
  608. - val SystemMessageResendInterval = config.getMillisDuration("system-message-resend-interval").requiring(interval ⇒
  609. + val SystemMessageResendInterval: FiniteDuration = config.getMillisDuration("system-message-resend-interval").requiring(interval ⇒
  610. interval > Duration.Zero, "system-message-resend-interval must be more than zero")
  611. - val HandshakeTimeout = config.getMillisDuration("handshake-timeout").requiring(interval ⇒
  612. + val HandshakeTimeout: FiniteDuration = config.getMillisDuration("handshake-timeout").requiring(interval ⇒
  613. interval > Duration.Zero, "handshake-timeout must be more than zero")
  614. - val HandshakeRetryInterval = config.getMillisDuration("handshake-retry-interval").requiring(interval ⇒
  615. + val HandshakeRetryInterval: FiniteDuration = config.getMillisDuration("handshake-retry-interval").requiring(interval ⇒
  616. interval > Duration.Zero, "handshake-retry-interval must be more than zero")
  617. - val InjectHandshakeInterval = config.getMillisDuration("inject-handshake-interval").requiring(interval ⇒
  618. + val InjectHandshakeInterval: FiniteDuration = config.getMillisDuration("inject-handshake-interval").requiring(interval ⇒
  619. interval > Duration.Zero, "inject-handshake-interval must be more than zero")
  620. - val GiveUpMessageAfter = config.getMillisDuration("give-up-message-after").requiring(interval ⇒
  621. + val GiveUpMessageAfter: FiniteDuration = config.getMillisDuration("give-up-message-after").requiring(interval ⇒
  622. interval > Duration.Zero, "give-up-message-after must be more than zero")
  623. - val GiveUpSystemMessageAfter = config.getMillisDuration("give-up-system-message-after").requiring(interval ⇒
  624. + val GiveUpSystemMessageAfter: FiniteDuration = config.getMillisDuration("give-up-system-message-after").requiring(interval ⇒
  625. interval > Duration.Zero, "give-up-system-message-after must be more than zero")
  626. - val ShutdownFlushTimeout = config.getMillisDuration("shutdown-flush-timeout").requiring(interval ⇒
  627. + val ShutdownFlushTimeout: FiniteDuration = config.getMillisDuration("shutdown-flush-timeout").requiring(interval ⇒
  628. interval > Duration.Zero, "shutdown-flush-timeout must be more than zero")
  629. - val InboundRestartTimeout = config.getMillisDuration("inbound-restart-timeout").requiring(interval ⇒
  630. + val InboundRestartTimeout: FiniteDuration = config.getMillisDuration("inbound-restart-timeout").requiring(interval ⇒
  631. interval > Duration.Zero, "inbound-restart-timeout must be more than zero")
  632. - val InboundMaxRestarts = getInt("inbound-max-restarts")
  633. - val OutboundRestartTimeout = config.getMillisDuration("outbound-restart-timeout").requiring(interval ⇒
  634. + val InboundMaxRestarts: Int = getInt("inbound-max-restarts")
  635. + val OutboundRestartTimeout: FiniteDuration = config.getMillisDuration("outbound-restart-timeout").requiring(interval ⇒
  636. interval > Duration.Zero, "outbound-restart-timeout must be more than zero")
  637. - val OutboundMaxRestarts = getInt("outbound-max-restarts")
  638. - val StopQuarantinedAfterIdle = config.getMillisDuration("stop-quarantined-after-idle").requiring(interval ⇒
  639. + val OutboundMaxRestarts: Int = getInt("outbound-max-restarts")
  640. + val StopQuarantinedAfterIdle: FiniteDuration = config.getMillisDuration("stop-quarantined-after-idle").requiring(interval ⇒
  641. interval > Duration.Zero, "stop-quarantined-after-idle must be more than zero")
  642. - val ClientLivenessTimeout = config.getMillisDuration("client-liveness-timeout").requiring(interval ⇒
  643. + val ClientLivenessTimeout: FiniteDuration = config.getMillisDuration("client-liveness-timeout").requiring(interval ⇒
  644. interval > Duration.Zero, "client-liveness-timeout must be more than zero")
  645. - val ImageLivenessTimeout = config.getMillisDuration("image-liveness-timeout").requiring(interval ⇒
  646. + val ImageLivenessTimeout: FiniteDuration = config.getMillisDuration("image-liveness-timeout").requiring(interval ⇒
  647. interval > Duration.Zero, "image-liveness-timeout must be more than zero")
  648. require(ImageLivenessTimeout < HandshakeTimeout, "image-liveness-timeout must be less than handshake-timeout")
  649. - val DriverTimeout = config.getMillisDuration("driver-timeout").requiring(interval ⇒
  650. + val DriverTimeout: FiniteDuration = config.getMillisDuration("driver-timeout").requiring(interval ⇒
  651. interval > Duration.Zero, "driver-timeout must be more than zero")
  652. val FlightRecorderEnabled: Boolean = getBoolean("flight-recorder.enabled")
  653. val FlightRecorderDestination: String = getString("flight-recorder.destination")
  654. - val Compression = new Compression(getConfig("compression"))
  655. + val Compression: Compression = new Compression(getConfig("compression"))
  656.  
  657. final val MaximumFrameSize: Int = math.min(getBytes("maximum-frame-size"), Int.MaxValue).toInt
  658. .requiring(_ >= 32 * 1024, "maximum-frame-size must be greater than or equal to 32 KiB")
  659. final val BufferPoolSize: Int = getInt("buffer-pool-size")
  660. .requiring(_ > 0, "buffer-pool-size must be greater than 0")
  661. - final val InboundHubBufferSize = BufferPoolSize / 2
  662. + final val InboundHubBufferSize: Int = BufferPoolSize / 2
  663. final val MaximumLargeFrameSize: Int = math.min(getBytes("maximum-large-frame-size"), Int.MaxValue).toInt
  664. .requiring(_ >= 32 * 1024, "maximum-large-frame-size must be greater than or equal to 32 KiB")
  665. final val LargeBufferPoolSize: Int = getInt("large-buffer-pool-size")
  666. @@ -155,7 +156,7 @@ private[akka] final class ArterySettings private (config: Config) {
  667.  
  668. /** INTERNAL API */
  669. private[akka] object ArterySettings {
  670. - def apply(config: Config) = new ArterySettings(config)
  671. + def apply(config: Config): ArterySettings = new ArterySettings(config)
  672.  
  673. /** INTERNAL API */
  674. private[remote] final class Compression private[ArterySettings] (config: Config) {
  675. @@ -164,18 +165,18 @@ private[akka] object ArterySettings {
  676. private[akka] final val Enabled = ActorRefs.Max > 0 || Manifests.Max > 0
  677.  
  678. object ActorRefs {
  679. - val config = getConfig("actor-refs")
  680. + val config: Config = getConfig("actor-refs")
  681. import config._
  682.  
  683. - val AdvertisementInterval = config.getMillisDuration("advertisement-interval")
  684. - val Max = getInt("max")
  685. + val AdvertisementInterval: FiniteDuration = config.getMillisDuration("advertisement-interval")
  686. + val Max: Int = getInt("max")
  687. }
  688. object Manifests {
  689. - val config = getConfig("manifests")
  690. + val config: Config = getConfig("manifests")
  691. import config._
  692.  
  693. - val AdvertisementInterval = config.getMillisDuration("advertisement-interval")
  694. - val Max = getInt("max")
  695. + val AdvertisementInterval: FiniteDuration = config.getMillisDuration("advertisement-interval")
  696. + val Max: Int = getInt("max")
  697. }
  698. }
  699. object Compression {
  700. @@ -183,7 +184,7 @@ private[akka] object ArterySettings {
  701. final val Debug = false // unlocks additional very verbose debug logging of compression events (to stdout)
  702. }
  703.  
  704. - def getHostname(key: String, config: Config) = config.getString(key) match {
  705. + def getHostname(key: String, config: Config): String = config.getString(key) match {
  706. case "<getHostAddress>" ⇒ InetAddress.getLocalHost.getHostAddress
  707. case "<getHostName>" ⇒ InetAddress.getLocalHost.getHostName
  708. case other ⇒ other
  709. diff --git a/akka-remote/src/main/scala/akka/remote/artery/ArteryTransport.scala b/akka-remote/src/main/scala/akka/remote/artery/ArteryTransport.scala
  710. index b7482c46d6..bdc402c1d9 100644
  711. --- a/akka-remote/src/main/scala/akka/remote/artery/ArteryTransport.scala
  712. +++ b/akka-remote/src/main/scala/akka/remote/artery/ArteryTransport.scala
  713. @@ -235,9 +235,9 @@ private[remote] object FlushOnShutdown {
  714. private[remote] class FlushOnShutdown(done: Promise[Done], timeout: FiniteDuration,
  715. inboundContext: InboundContext, associations: Set[Association]) extends Actor {
  716.  
  717. - var remaining = Map.empty[UniqueAddress, Int]
  718. + var remaining: Map[UniqueAddress, Int] = Map.empty[UniqueAddress, Int]
  719.  
  720. - val timeoutTask = context.system.scheduler.scheduleOnce(timeout, self, FlushOnShutdown.Timeout)(context.dispatcher)
  721. + val timeoutTask: Cancellable = context.system.scheduler.scheduleOnce(timeout, self, FlushOnShutdown.Timeout)(context.dispatcher)
  722.  
  723. override def preStart(): Unit = {
  724. try {
  725. @@ -265,7 +265,7 @@ private[remote] class FlushOnShutdown(done: Promise[Done], timeout: FiniteDurati
  726. done.trySuccess(Done)
  727. }
  728.  
  729. - def receive = {
  730. + def receive: PartialFunction[Any, Unit] = {
  731. case ActorSystemTerminatingAck(from) ⇒
  732. // Just treat unexpected acks as systems from which zero acks are expected
  733. val acksRemaining = remaining.getOrElse(from, 0)
  734. @@ -972,7 +972,7 @@ private[remote] class ArteryTransport(_system: ExtendedActorSystem, _provider: R
  735. }
  736.  
  737. // InboundContext
  738. - override def sendControl(to: Address, message: ControlMessage) =
  739. + override def sendControl(to: Address, message: ControlMessage): Unit =
  740. try {
  741. association(to).sendControl(message)
  742. } catch {
  743. diff --git a/akka-remote/src/main/scala/akka/remote/artery/Association.scala b/akka-remote/src/main/scala/akka/remote/artery/Association.scala
  744. index 99ded3a261..48d27fc644 100644
  745. --- a/akka-remote/src/main/scala/akka/remote/artery/Association.scala
  746. +++ b/akka-remote/src/main/scala/akka/remote/artery/Association.scala
  747. @@ -119,7 +119,7 @@ private[remote] class Association(
  748. private val log = Logging(transport.system, getClass.getName)
  749. private val flightRecorder = transport.createFlightRecorderEventSink(synchr = true)
  750.  
  751. - override def settings = transport.settings
  752. + override def settings: ArterySettings = transport.settings
  753. private def advancedSettings = transport.settings.Advanced
  754.  
  755. private val restartCounter = new RestartCounter(advancedSettings.OutboundMaxRestarts, advancedSettings.OutboundRestartTimeout)
  756. diff --git a/akka-remote/src/main/scala/akka/remote/artery/BufferPool.scala b/akka-remote/src/main/scala/akka/remote/artery/BufferPool.scala
  757. index 5957ab684f..e4751d3309 100644
  758. --- a/akka-remote/src/main/scala/akka/remote/artery/BufferPool.scala
  759. +++ b/akka-remote/src/main/scala/akka/remote/artery/BufferPool.scala
  760. @@ -37,7 +37,7 @@ private[remote] class EnvelopeBufferPool(maximumPayload: Int, maximumBuffers: In
  761. }
  762. }
  763.  
  764. - def release(buffer: EnvelopeBuffer) =
  765. + def release(buffer: EnvelopeBuffer): Unit =
  766. if (buffer.byteBuffer.isDirect && !availableBuffers.offer(buffer)) buffer.tryCleanDirectByteBuffer()
  767.  
  768. }
  769. @@ -45,7 +45,7 @@ private[remote] class EnvelopeBufferPool(maximumPayload: Int, maximumBuffers: In
  770. /** INTERNAL API */
  771. private[remote] final class ByteFlag(val mask: Byte) extends AnyVal {
  772. def isEnabled(byteFlags: Byte): Boolean = (byteFlags.toInt & mask) != 0
  773. - override def toString = s"ByteFlag(${ByteFlag.binaryLeftPad(mask)})"
  774. + override def toString: String = s"ByteFlag(${ByteFlag.binaryLeftPad(mask)})"
  775. }
  776. /**
  777. * INTERNAL API
  778. @@ -67,7 +67,7 @@ private[remote] object EnvelopeBuffer {
  779. val TagValueMask = 0x0000FFFF
  780.  
  781. // Flags (1 byte allocated for them)
  782. - val MetadataPresentFlag = new ByteFlag(0x1)
  783. + val MetadataPresentFlag: ByteFlag = new ByteFlag(0x1)
  784.  
  785. val VersionOffset = 0 // Byte
  786. val FlagsOffset = 1 // Byte
  787. @@ -231,17 +231,17 @@ private[remote] final class HeaderBuilderImpl(
  788. _remoteInstruments = OptionVal.None
  789. }
  790.  
  791. - override def setVersion(v: Byte) = _version = v
  792. - override def version = _version
  793. + override def setVersion(v: Byte): Unit = _version = v
  794. + override def version: Byte = _version
  795.  
  796. - override def setFlags(v: Byte) = _flags = v
  797. - override def flags = _flags
  798. + override def setFlags(v: Byte): Unit = _flags = v
  799. + override def flags: Byte = _flags
  800. override def flag(byteFlag: ByteFlag): Boolean = (_flags.toInt & byteFlag.mask) != 0
  801. override def setFlag(byteFlag: ByteFlag, value: Boolean): Unit =
  802. if (value) _flags = (flags | byteFlag.mask).toByte
  803. else _flags = (flags & ~byteFlag.mask).toByte
  804.  
  805. - override def setUid(uid: Long) = _uid = uid
  806. + override def setUid(uid: Long): Unit = _uid = uid
  807. override def uid: Long = _uid
  808.  
  809. override def inboundActorRefCompressionTableVersion: Byte = _inboundActorRefCompressionTableVersion
  810. @@ -333,7 +333,7 @@ private[remote] final class HeaderBuilderImpl(
  811. _remoteInstruments = OptionVal(instruments)
  812. }
  813.  
  814. - override def toString =
  815. + override def toString: String =
  816. "HeaderBuilderImpl(" +
  817. "version:" + version + ", " +
  818. "flags:" + ByteFlag.binaryLeftPad(flags) + ", " +
  819. @@ -353,7 +353,7 @@ private[remote] final class HeaderBuilderImpl(
  820. */
  821. private[remote] final class EnvelopeBuffer(val byteBuffer: ByteBuffer) {
  822. import EnvelopeBuffer._
  823. - val aeronBuffer = new UnsafeBuffer(byteBuffer)
  824. + val aeronBuffer: UnsafeBuffer = new UnsafeBuffer(byteBuffer)
  825.  
  826. private var literalChars = new Array[Char](64)
  827. private var literalBytes = new Array[Byte](64)
  828. diff --git a/akka-remote/src/main/scala/akka/remote/artery/Codecs.scala b/akka-remote/src/main/scala/akka/remote/artery/Codecs.scala
  829. index e019d20c36..0ff0eaef6e 100644
  830. --- a/akka-remote/src/main/scala/akka/remote/artery/Codecs.scala
  831. +++ b/akka-remote/src/main/scala/akka/remote/artery/Codecs.scala
  832. @@ -85,7 +85,7 @@ private[remote] class Encoder(
  833. done.success(Done)
  834. }
  835.  
  836. - override protected def logSource = classOf[Encoder]
  837. + override protected def logSource: Class[Encoder] = classOf[Encoder]
  838.  
  839. private var debugLogSendEnabled = false
  840.  
  841. @@ -356,7 +356,7 @@ private[remote] class Decoder(
  842. val logic = new TimerGraphStageLogic(shape) with InboundCompressionAccessImpl with InHandler with OutHandler with StageLogging {
  843. import Decoder.RetryResolveRemoteDeployedRecipient
  844.  
  845. - override val compressions = inboundCompressions
  846. + override val compressions: InboundCompressions = inboundCompressions
  847.  
  848. private val localAddress = inboundContext.localAddress.address
  849. private val headerBuilder = HeaderBuilder.in(compressions)
  850. @@ -374,7 +374,7 @@ private[remote] class Decoder(
  851. private var tickTimestamp = System.nanoTime()
  852. private var tickMessageCount = 0L
  853.  
  854. - override protected def logSource = classOf[Decoder]
  855. + override protected def logSource: Class[Decoder] = classOf[Decoder]
  856.  
  857. override def preStart(): Unit = {
  858. schedulePeriodically(Tick, 1.seconds)
  859. @@ -611,7 +611,7 @@ private[remote] class Deserializer(
  860. private val instruments: RemoteInstruments = RemoteInstruments(system)
  861. private val serialization = SerializationExtension(system)
  862.  
  863. - override protected def logSource = classOf[Deserializer]
  864. + override protected def logSource: Class[Deserializer] = classOf[Deserializer]
  865.  
  866. override def onPush(): Unit = {
  867. val envelope = grab(in)
  868. diff --git a/akka-remote/src/main/scala/akka/remote/artery/Control.scala b/akka-remote/src/main/scala/akka/remote/artery/Control.scala
  869. index ead5d99372..b742174ce4 100644
  870. --- a/akka-remote/src/main/scala/akka/remote/artery/Control.scala
  871. +++ b/akka-remote/src/main/scala/akka/remote/artery/Control.scala
  872. @@ -91,7 +91,7 @@ private[remote] class InboundControlJunction
  873. val out: Outlet[InboundEnvelope] = Outlet("InboundControlJunction.out")
  874. override val shape: FlowShape[InboundEnvelope, InboundEnvelope] = FlowShape(in, out)
  875.  
  876. - override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
  877. + override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic with InHandler with OutHandler with ControlMessageSubject, GraphStageLogic with InHandler with OutHandler with ControlMessageSubject) = {
  878. val stoppedPromise = Promise[Done]()
  879. val logic = new GraphStageLogic(shape) with InHandler with OutHandler with ControlMessageSubject {
  880.  
  881. @@ -161,12 +161,12 @@ private[remote] class OutboundControlJunction(
  882. val out: Outlet[OutboundEnvelope] = Outlet("OutboundControlJunction.out")
  883. override val shape: FlowShape[OutboundEnvelope, OutboundEnvelope] = FlowShape(in, out)
  884.  
  885. - override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
  886. + override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic with InHandler with OutHandler with StageLogging with OutboundControlIngress, GraphStageLogic with InHandler with OutHandler with StageLogging with OutboundControlIngress) = {
  887.  
  888. val logic = new GraphStageLogic(shape) with InHandler with OutHandler with StageLogging with OutboundControlIngress {
  889. import OutboundControlJunction._
  890.  
  891. - val sendControlMessageCallback = getAsyncCallback[ControlMessage](internalSendControlMessage)
  892. + val sendControlMessageCallback: AsyncCallback[ControlMessage] = getAsyncCallback[ControlMessage](internalSendControlMessage)
  893. private val maxControlMessageBufferSize: Int = outboundContext.settings.Advanced.OutboundControlQueueSize
  894. private val buffer = new ArrayDeque[OutboundEnvelope]
  895.  
  896. diff --git a/akka-remote/src/main/scala/akka/remote/artery/FlightRecorder.scala b/akka-remote/src/main/scala/akka/remote/artery/FlightRecorder.scala
  897. index 823e877ff7..c0461a62d4 100644
  898. --- a/akka-remote/src/main/scala/akka/remote/artery/FlightRecorder.scala
  899. +++ b/akka-remote/src/main/scala/akka/remote/artery/FlightRecorder.scala
  900. @@ -224,39 +224,39 @@ private[remote] object FlightRecorder {
  901. FileChannel.open(path, StandardOpenOption.CREATE, StandardOpenOption.WRITE, StandardOpenOption.READ)
  902. }
  903.  
  904. - val Alignment = 64 * 1024 // Windows is picky about mapped section alignments
  905. + val Alignment: Int = 64 * 1024 // Windows is picky about mapped section alignments
  906.  
  907. val MagicString = 0x31524641 // "AFR1", little-endian
  908. - val GlobalSectionSize = BitUtil.align(24, Alignment)
  909. + val GlobalSectionSize: Int = BitUtil.align(24, Alignment)
  910. val StartTimeStampOffset = 4
  911.  
  912. val LogHeaderSize = 16
  913. val SnapshotCount = 4
  914. - val SnapshotMask = SnapshotCount - 1
  915. + val SnapshotMask: Int = SnapshotCount - 1
  916.  
  917. // TODO: Dummy values right now, format is under construction
  918. val AlertRecordSize = 128
  919. val LoFreqRecordSize = 128
  920. val HiFreqBatchSize = 62
  921. - val HiFreqRecordSize = 16 * (HiFreqBatchSize + 2) // (batched events + header)
  922. + val HiFreqRecordSize: Int = 16 * (HiFreqBatchSize + 2) // (batched events + header)
  923.  
  924. val AlertWindow = 256
  925. val LoFreqWindow = 256
  926. val HiFreqWindow = 256 // This is counted in batches !
  927.  
  928. - val AlertLogSize = BitUtil.align(LogHeaderSize + (AlertWindow * AlertRecordSize), Alignment)
  929. - val LoFreqLogSize = BitUtil.align(LogHeaderSize + (LoFreqWindow * LoFreqRecordSize), Alignment)
  930. - val HiFreqLogSize = BitUtil.align(LogHeaderSize + (HiFreqWindow * HiFreqRecordSize), Alignment)
  931. + val AlertLogSize: Int = BitUtil.align(LogHeaderSize + (AlertWindow * AlertRecordSize), Alignment)
  932. + val LoFreqLogSize: Int = BitUtil.align(LogHeaderSize + (LoFreqWindow * LoFreqRecordSize), Alignment)
  933. + val HiFreqLogSize: Int = BitUtil.align(LogHeaderSize + (HiFreqWindow * HiFreqRecordSize), Alignment)
  934.  
  935. - val AlertSectionSize = AlertLogSize * SnapshotCount
  936. - val LoFreqSectionSize = LoFreqLogSize * SnapshotCount
  937. - val HiFreqSectionSize = HiFreqLogSize * SnapshotCount
  938. + val AlertSectionSize: Int = AlertLogSize * SnapshotCount
  939. + val LoFreqSectionSize: Int = LoFreqLogSize * SnapshotCount
  940. + val HiFreqSectionSize: Int = HiFreqLogSize * SnapshotCount
  941.  
  942. - val AlertSectionOffset = GlobalSectionSize
  943. - val LoFreqSectionOffset = GlobalSectionSize + AlertSectionSize
  944. - val HiFreqSectionOffset = GlobalSectionSize + AlertSectionSize + LoFreqSectionSize
  945. + val AlertSectionOffset: Int = GlobalSectionSize
  946. + val LoFreqSectionOffset: Int = GlobalSectionSize + AlertSectionSize
  947. + val HiFreqSectionOffset: Int = GlobalSectionSize + AlertSectionSize + LoFreqSectionSize
  948.  
  949. - val TotalSize = GlobalSectionSize + AlertSectionSize + LoFreqSectionSize + HiFreqSectionSize
  950. + val TotalSize: Int = GlobalSectionSize + AlertSectionSize + LoFreqSectionSize + HiFreqSectionSize
  951.  
  952. val HiFreqEntryCountFieldOffset = 16
  953. }
  954. diff --git a/akka-remote/src/main/scala/akka/remote/artery/FlightRecorderEvents.scala b/akka-remote/src/main/scala/akka/remote/artery/FlightRecorderEvents.scala
  955. index c1d585fd3c..7a6a6d2787 100644
  956. --- a/akka-remote/src/main/scala/akka/remote/artery/FlightRecorderEvents.scala
  957. +++ b/akka-remote/src/main/scala/akka/remote/artery/FlightRecorderEvents.scala
  958. @@ -7,7 +7,7 @@ private[remote] object FlightRecorderEvents {
  959.  
  960. // Note: Remember to update dictionary when adding new events!
  961.  
  962. - val NoMetaData = Array.empty[Byte]
  963. + val NoMetaData: Array[Byte] = Array.empty[Byte]
  964.  
  965. // Top level remoting events
  966. val Transport_MediaDriverStarted = 0
  967. @@ -52,7 +52,7 @@ private[remote] object FlightRecorderEvents {
  968. val Compression_Inbound_RunClassManifestAdvertisement = 95
  969.  
  970. // Used for presentation of the entries in the flight recorder
  971. - lazy val eventDictionary = Map(
  972. + lazy val eventDictionary: Map[Long, String] = Map(
  973. Transport_MediaDriverStarted → "Transport: Media driver started",
  974. Transport_AeronStarted → "Transport: Aeron started",
  975. Transport_AeronErrorLogStarted → "Transport: Aeron error log started",
  976. diff --git a/akka-remote/src/main/scala/akka/remote/artery/FlightRecorderReader.scala b/akka-remote/src/main/scala/akka/remote/artery/FlightRecorderReader.scala
  977. index d3efcdeb53..dd7d6cbb16 100644
  978. --- a/akka-remote/src/main/scala/akka/remote/artery/FlightRecorderReader.scala
  979. +++ b/akka-remote/src/main/scala/akka/remote/artery/FlightRecorderReader.scala
  980. @@ -16,7 +16,7 @@ import scala.collection.{ SortedSet, immutable }
  981. */
  982. object FlightRecorderDump extends App {
  983. require(args.size == 1, "Usage: FlightRecorderDump afr-file")
  984. - val path = FileSystems.getDefault.getPath(args(0))
  985. + val path: Path = FileSystems.getDefault.getPath(args(0))
  986. FlightRecorderReader.dumpToStdout(path)
  987. }
  988.  
  989. @@ -50,7 +50,7 @@ private[akka] object FlightRecorderReader {
  990. """.stripMargin
  991. }
  992.  
  993. - val AlertSectionParameters = SectionParameters(
  994. + val AlertSectionParameters: SectionParameters = SectionParameters(
  995. offset = AlertSectionOffset,
  996. sectionSize = AlertSectionSize,
  997. logSize = AlertLogSize,
  998. @@ -58,7 +58,7 @@ private[akka] object FlightRecorderReader {
  999. recordSize = AlertRecordSize,
  1000. entriesPerRecord = 1)
  1001.  
  1002. - val LoFreqSectionParameters = SectionParameters(
  1003. + val LoFreqSectionParameters: SectionParameters = SectionParameters(
  1004. offset = LoFreqSectionOffset,
  1005. sectionSize = LoFreqSectionSize,
  1006. logSize = LoFreqLogSize,
  1007. @@ -66,7 +66,7 @@ private[akka] object FlightRecorderReader {
  1008. recordSize = LoFreqRecordSize,
  1009. entriesPerRecord = 1)
  1010.  
  1011. - val HiFreqSectionParameters = SectionParameters(
  1012. + val HiFreqSectionParameters: SectionParameters = SectionParameters(
  1013. offset = HiFreqSectionOffset,
  1014. sectionSize = HiFreqSectionSize,
  1015. logSize = HiFreqLogSize,
  1016. @@ -138,8 +138,8 @@ private[akka] final class FlightRecorderReader(fileChannel: FileChannel) {
  1017.  
  1018. def richEntries: Iterator[RichEntry] = {
  1019. new Iterator[RichEntry] {
  1020. - var recordOffset = offset + RollingEventLogSection.RecordsOffset
  1021. - var recordsLeft = math.min(head, sectionParameters.window)
  1022. + var recordOffset: Long = offset + RollingEventLogSection.RecordsOffset
  1023. + var recordsLeft: Long = math.min(head, sectionParameters.window)
  1024.  
  1025. override def hasNext: Boolean = recordsLeft > 0
  1026.  
  1027. @@ -164,9 +164,9 @@ private[akka] final class FlightRecorderReader(fileChannel: FileChannel) {
  1028.  
  1029. def compactEntries: Iterator[CompactEntry] = {
  1030. new Iterator[CompactEntry] {
  1031. - var recordOffset = offset + RollingEventLogSection.RecordsOffset
  1032. - var entryOffset = recordOffset + RollingEventLogSection.CommitEntrySize
  1033. - var recordsLeft = math.min(head, sectionParameters.window)
  1034. + var recordOffset: Long = offset + RollingEventLogSection.RecordsOffset
  1035. + var entryOffset: Long = recordOffset + RollingEventLogSection.CommitEntrySize
  1036. + var recordsLeft: Long = math.min(head, sectionParameters.window)
  1037. var entriesLeft = -1L
  1038. var dirty = false
  1039. var timeStamp: Instant = _
  1040. diff --git a/akka-remote/src/main/scala/akka/remote/artery/InboundEnvelope.scala b/akka-remote/src/main/scala/akka/remote/artery/InboundEnvelope.scala
  1041. index 8e67a07dc4..07ef29945b 100644
  1042. --- a/akka-remote/src/main/scala/akka/remote/artery/InboundEnvelope.scala
  1043. +++ b/akka-remote/src/main/scala/akka/remote/artery/InboundEnvelope.scala
  1044. @@ -59,7 +59,7 @@ private[remote] trait InboundEnvelope {
  1045. * INTERNAL API
  1046. */
  1047. private[remote] object ReusableInboundEnvelope {
  1048. - def createObjectPool(capacity: Int) = new ObjectPool[ReusableInboundEnvelope](
  1049. + def createObjectPool(capacity: Int): ObjectPool[ReusableInboundEnvelope] = new ObjectPool[ReusableInboundEnvelope](
  1050. capacity,
  1051. create = () ⇒ new ReusableInboundEnvelope, clear = inEnvelope ⇒ inEnvelope.asInstanceOf[ReusableInboundEnvelope].clear())
  1052. }
  1053. diff --git a/akka-remote/src/main/scala/akka/remote/artery/InboundQuarantineCheck.scala b/akka-remote/src/main/scala/akka/remote/artery/InboundQuarantineCheck.scala
  1054. index 18501a504b..aae70082fd 100644
  1055. --- a/akka-remote/src/main/scala/akka/remote/artery/InboundQuarantineCheck.scala
  1056. +++ b/akka-remote/src/main/scala/akka/remote/artery/InboundQuarantineCheck.scala
  1057. @@ -25,7 +25,7 @@ private[remote] class InboundQuarantineCheck(inboundContext: InboundContext) ext
  1058. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  1059. new GraphStageLogic(shape) with InHandler with OutHandler with StageLogging {
  1060.  
  1061. - override protected def logSource = classOf[InboundQuarantineCheck]
  1062. + override protected def logSource: Class[InboundQuarantineCheck] = classOf[InboundQuarantineCheck]
  1063.  
  1064. // InHandler
  1065. override def onPush(): Unit = {
  1066. diff --git a/akka-remote/src/main/scala/akka/remote/artery/LruBoundedCache.scala b/akka-remote/src/main/scala/akka/remote/artery/LruBoundedCache.scala
  1067. index 06b8c4c272..e099f43f0f 100644
  1068. --- a/akka-remote/src/main/scala/akka/remote/artery/LruBoundedCache.scala
  1069. +++ b/akka-remote/src/main/scala/akka/remote/artery/LruBoundedCache.scala
  1070. @@ -130,7 +130,7 @@ private[akka] abstract class LruBoundedCache[K: ClassTag, V <: AnyRef: ClassTag]
  1071. private def probeDistanceOf(slot: Int): Int = probeDistanceOf(idealSlot = hashes(slot) & Mask, actualSlot = slot)
  1072.  
  1073. // Protected for exposing it to unit tests
  1074. - protected def probeDistanceOf(idealSlot: Int, actualSlot: Int) = ((actualSlot - idealSlot) + capacity) & Mask
  1075. + protected def probeDistanceOf(idealSlot: Int, actualSlot: Int): Int = ((actualSlot - idealSlot) + capacity) & Mask
  1076.  
  1077. @tailrec private def move(position: Int, k: K, h: Int, value: V, elemEpoch: Int, probeDistance: Int): Unit = {
  1078. if (values(position) eq null) {
  1079. @@ -181,7 +181,7 @@ private[akka] abstract class LruBoundedCache[K: ClassTag, V <: AnyRef: ClassTag]
  1080.  
  1081. protected def isCacheable(v: V): Boolean
  1082.  
  1083. - override def toString =
  1084. + override def toString: String =
  1085. s"LruBoundedCache(" +
  1086. s" values = ${values.mkString("[", ",", "]")}," +
  1087. s" hashes = ${hashes.map(_ & Mask).mkString("[", ",", "]")}," +
  1088. diff --git a/akka-remote/src/main/scala/akka/remote/artery/OutboundEnvelope.scala b/akka-remote/src/main/scala/akka/remote/artery/OutboundEnvelope.scala
  1089. index b95b623c83..a97b319827 100644
  1090. --- a/akka-remote/src/main/scala/akka/remote/artery/OutboundEnvelope.scala
  1091. +++ b/akka-remote/src/main/scala/akka/remote/artery/OutboundEnvelope.scala
  1092. @@ -38,7 +38,7 @@ private[remote] trait OutboundEnvelope {
  1093. * INTERNAL API
  1094. */
  1095. private[remote] object ReusableOutboundEnvelope {
  1096. - def createObjectPool(capacity: Int) = new ObjectPool[ReusableOutboundEnvelope](
  1097. + def createObjectPool(capacity: Int): ObjectPool[ReusableOutboundEnvelope] = new ObjectPool[ReusableOutboundEnvelope](
  1098. capacity,
  1099. create = () ⇒ new ReusableOutboundEnvelope, clear = outEnvelope ⇒ outEnvelope.clear())
  1100. }
  1101. diff --git a/akka-remote/src/main/scala/akka/remote/artery/RemoteInstrument.scala b/akka-remote/src/main/scala/akka/remote/artery/RemoteInstrument.scala
  1102. index e2097cd78a..8175ed0538 100644
  1103. --- a/akka-remote/src/main/scala/akka/remote/artery/RemoteInstrument.scala
  1104. +++ b/akka-remote/src/main/scala/akka/remote/artery/RemoteInstrument.scala
  1105. @@ -271,7 +271,7 @@ private[remote] final class RemoteInstruments(
  1106.  
  1107. def isEmpty: Boolean = instruments.isEmpty
  1108. def nonEmpty: Boolean = instruments.nonEmpty
  1109. - def timeSerialization = serializationTimingEnabled
  1110. + def timeSerialization: Boolean = serializationTimingEnabled
  1111. }
  1112.  
  1113. /** INTERNAL API */
  1114. diff --git a/akka-remote/src/main/scala/akka/remote/artery/SystemMessageDelivery.scala b/akka-remote/src/main/scala/akka/remote/artery/SystemMessageDelivery.scala
  1115. index d87b24db63..d77dd0d649 100644
  1116. --- a/akka-remote/src/main/scala/akka/remote/artery/SystemMessageDelivery.scala
  1117. +++ b/akka-remote/src/main/scala/akka/remote/artery/SystemMessageDelivery.scala
  1118. @@ -271,9 +271,9 @@ private[remote] class SystemMessageAcker(inboundContext: InboundContext) extends
  1119. new GraphStageLogic(shape) with InHandler with OutHandler {
  1120.  
  1121. // TODO we might need have to prune old unused entries
  1122. - var sequenceNumbers = Map.empty[UniqueAddress, Long]
  1123. + var sequenceNumbers: Map[UniqueAddress, Long] = Map.empty[UniqueAddress, Long]
  1124.  
  1125. - def localAddress = inboundContext.localAddress
  1126. + def localAddress: UniqueAddress = inboundContext.localAddress
  1127.  
  1128. // InHandler
  1129. override def onPush(): Unit = {
  1130. diff --git a/akka-remote/src/main/scala/akka/remote/artery/TestStage.scala b/akka-remote/src/main/scala/akka/remote/artery/TestStage.scala
  1131. index bff26033c1..9556e26d8f 100644
  1132. --- a/akka-remote/src/main/scala/akka/remote/artery/TestStage.scala
  1133. +++ b/akka-remote/src/main/scala/akka/remote/artery/TestStage.scala
  1134. @@ -113,7 +113,7 @@ private[remote] class OutboundTestStage(outboundContext: OutboundContext, state:
  1135. val out: Outlet[OutboundEnvelope] = Outlet("OutboundTestStage.out")
  1136. override val shape: FlowShape[OutboundEnvelope, OutboundEnvelope] = FlowShape(in, out)
  1137.  
  1138. - override def createLogic(inheritedAttributes: Attributes) = {
  1139. + override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = {
  1140. if (enabled) {
  1141. new TimerGraphStageLogic(shape) with InHandler with OutHandler with StageLogging {
  1142.  
  1143. @@ -154,7 +154,7 @@ private[remote] class InboundTestStage(inboundContext: InboundContext, state: Sh
  1144. val out: Outlet[InboundEnvelope] = Outlet("InboundTestStage.out")
  1145. override val shape: FlowShape[InboundEnvelope, InboundEnvelope] = FlowShape(in, out)
  1146.  
  1147. - override def createLogic(inheritedAttributes: Attributes) = {
  1148. + override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = {
  1149. if (enabled) {
  1150. new TimerGraphStageLogic(shape) with InHandler with OutHandler with StageLogging {
  1151.  
  1152. diff --git a/akka-remote/src/main/scala/akka/remote/artery/compress/CompressionTable.scala b/akka-remote/src/main/scala/akka/remote/artery/compress/CompressionTable.scala
  1153. index 60c7079803..97bb66b385 100644
  1154. --- a/akka-remote/src/main/scala/akka/remote/artery/compress/CompressionTable.scala
  1155. +++ b/akka-remote/src/main/scala/akka/remote/artery/compress/CompressionTable.scala
  1156. @@ -62,5 +62,5 @@ private[remote] object CompressionTable {
  1157. def compareBy2ndValue[T]: Comparator[Tuple2[T, Int]] = CompareBy2ndValue.asInstanceOf[Comparator[(T, Int)]]
  1158.  
  1159. private[this] val _empty = new CompressionTable[Any](0, 0, Map.empty)
  1160. - def empty[T] = _empty.asInstanceOf[CompressionTable[T]]
  1161. + def empty[T]: CompressionTable[T] = _empty.asInstanceOf[CompressionTable[T]]
  1162. }
  1163. diff --git a/akka-remote/src/main/scala/akka/remote/artery/compress/DecompressionTable.scala b/akka-remote/src/main/scala/akka/remote/artery/compress/DecompressionTable.scala
  1164. index bd671259ab..61f8f389c0 100644
  1165. --- a/akka-remote/src/main/scala/akka/remote/artery/compress/DecompressionTable.scala
  1166. +++ b/akka-remote/src/main/scala/akka/remote/artery/compress/DecompressionTable.scala
  1167. @@ -24,7 +24,7 @@ private[remote] final case class DecompressionTable[T](originUid: Long, version:
  1168. CompressionTable(originUid, version, Map(table.zipWithIndex: _*))
  1169.  
  1170. /** Writes complete table as String (heavy operation) */
  1171. - override def toString =
  1172. + override def toString: String =
  1173. s"DecompressionTable($originUid, $version, " +
  1174. s"Map(${table.zipWithIndex.map({ case (t, i) ⇒ s"$i -> $t" }).mkString(",")}))"
  1175. }
  1176. @@ -35,6 +35,6 @@ private[remote] object DecompressionTable {
  1177. val DisabledVersion: Byte = -1
  1178.  
  1179. private[this] val _empty = DecompressionTable(0, 0, Array.empty)
  1180. - def empty[T] = _empty.asInstanceOf[DecompressionTable[T]]
  1181. - def disabled[T] = empty[T].copy(version = DisabledVersion)
  1182. + def empty[T]: DecompressionTable[T] = _empty.asInstanceOf[DecompressionTable[T]]
  1183. + def disabled[T]: DecompressionTable[T] = empty[T].copy(version = DisabledVersion)
  1184. }
  1185. diff --git a/akka-remote/src/main/scala/akka/remote/artery/compress/InboundCompressions.scala b/akka-remote/src/main/scala/akka/remote/artery/compress/InboundCompressions.scala
  1186. index c935435e14..3a6699cbf7 100644
  1187. --- a/akka-remote/src/main/scala/akka/remote/artery/compress/InboundCompressions.scala
  1188. +++ b/akka-remote/src/main/scala/akka/remote/artery/compress/InboundCompressions.scala
  1189. @@ -207,7 +207,7 @@ private[remote] object InboundCompression {
  1190. final val KeepOldTablesNumber = 3 // TODO could be configurable
  1191.  
  1192. object Tables {
  1193. - def empty[T] = Tables(
  1194. + def empty[T]: Tables[T] = Tables(
  1195. oldTables = List(DecompressionTable.disabled[T]),
  1196. activeTable = DecompressionTable.empty[T],
  1197. nextTable = DecompressionTable.empty[T].copy(version = 1),
  1198. @@ -451,7 +451,7 @@ private[remote] abstract class InboundCompression[T >: Null](
  1199. CompressionTable(originUid, nextTableVersion, mappings)
  1200. }
  1201.  
  1202. - override def toString =
  1203. + override def toString: String =
  1204. s"""${Logging.simpleName(getClass)}(countMinSketch: $cms, heavyHitters: $heavyHitters)"""
  1205.  
  1206. }
  1207. diff --git a/akka-remote/src/main/scala/akka/remote/artery/compress/TopHeavyHitters.scala b/akka-remote/src/main/scala/akka/remote/artery/compress/TopHeavyHitters.scala
  1208. index 5492e81dfd..29d920f933 100644
  1209. --- a/akka-remote/src/main/scala/akka/remote/artery/compress/TopHeavyHitters.scala
  1210. +++ b/akka-remote/src/main/scala/akka/remote/artery/compress/TopHeavyHitters.scala
  1211. @@ -27,8 +27,8 @@ private[remote] final class TopHeavyHitters[T >: Null](val max: Int)(implicit cl
  1212.  
  1213. require((max & (max - 1)) == 0, "Maximum numbers of heavy hitters should be in form of 2^k for any natural k")
  1214.  
  1215. - val capacity = max * 2
  1216. - val mask = capacity - 1
  1217. + val capacity: Int = max * 2
  1218. + val mask: Int = capacity - 1
  1219.  
  1220. import TopHeavyHitters._
  1221.  
  1222. @@ -120,7 +120,7 @@ private[remote] final class TopHeavyHitters[T >: Null](val max: Int)(implicit cl
  1223. }
  1224. }
  1225.  
  1226. - def toDebugString =
  1227. + def toDebugString: String =
  1228. s"""TopHeavyHitters(
  1229. | max: $max,
  1230. | lowestHitterIdx: $lowestHitterIndex (weight: $lowestHitterWeight)
  1231. @@ -389,7 +389,7 @@ private[remote] final class TopHeavyHitters[T >: Null](val max: Int)(implicit cl
  1232. heap(0)
  1233. }
  1234.  
  1235. - override def toString =
  1236. + override def toString: String =
  1237. s"${getClass.getSimpleName}(max:$max)"
  1238. }
  1239.  
  1240. diff --git a/akka-remote/src/main/scala/akka/remote/security/provider/AkkaProvider.scala b/akka-remote/src/main/scala/akka/remote/security/provider/AkkaProvider.scala
  1241. index 7fd441cb87..cd429b26a4 100644
  1242. --- a/akka-remote/src/main/scala/akka/remote/security/provider/AkkaProvider.scala
  1243. +++ b/akka-remote/src/main/scala/akka/remote/security/provider/AkkaProvider.scala
  1244. @@ -10,7 +10,7 @@ import java.security.{ PrivilegedAction, AccessController, Provider }
  1245. */
  1246. object AkkaProvider extends Provider("Akka", 1.0, "Akka provider 1.0 that implements a secure AES random number generator") {
  1247. AccessController.doPrivileged(new PrivilegedAction[this.type] {
  1248. - def run = {
  1249. + def run: Null = {
  1250. //SecureRandom
  1251. put("SecureRandom.AES128CounterSecureRNG", classOf[AES128CounterSecureRNG].getName)
  1252. put("SecureRandom.AES256CounterSecureRNG", classOf[AES256CounterSecureRNG].getName)
  1253. diff --git a/akka-remote/src/main/scala/akka/remote/serialization/ActorRefResolveCache.scala b/akka-remote/src/main/scala/akka/remote/serialization/ActorRefResolveCache.scala
  1254. index 04326bbfb2..891d0338f1 100644
  1255. --- a/akka-remote/src/main/scala/akka/remote/serialization/ActorRefResolveCache.scala
  1256. +++ b/akka-remote/src/main/scala/akka/remote/serialization/ActorRefResolveCache.scala
  1257. @@ -22,7 +22,7 @@ private[akka] object ActorRefResolveThreadLocalCache
  1258.  
  1259. override def get(system: ActorSystem): ActorRefResolveThreadLocalCache = super.get(system)
  1260.  
  1261. - override def lookup = ActorRefResolveThreadLocalCache
  1262. + override def lookup: ActorRefResolveThreadLocalCache.type = ActorRefResolveThreadLocalCache
  1263.  
  1264. override def createExtension(system: ExtendedActorSystem): ActorRefResolveThreadLocalCache =
  1265. new ActorRefResolveThreadLocalCache(system)
  1266. diff --git a/akka-remote/src/main/scala/akka/remote/transport/AbstractTransportAdapter.scala b/akka-remote/src/main/scala/akka/remote/transport/AbstractTransportAdapter.scala
  1267. index 9fd78211b7..6846a33634 100644
  1268. --- a/akka-remote/src/main/scala/akka/remote/transport/AbstractTransportAdapter.scala
  1269. +++ b/akka-remote/src/main/scala/akka/remote/transport/AbstractTransportAdapter.scala
  1270. @@ -15,6 +15,7 @@ import scala.concurrent.{ ExecutionContext, Promise, Future }
  1271. import akka.dispatch.{ UnboundedMessageQueueSemantics, RequiresMessageQueue }
  1272. import akka.remote.transport.AssociationHandle.DisassociateInfo
  1273. import akka.actor.DeadLetterSuppression
  1274. +import akka.remote.RemoteSettings
  1275.  
  1276. trait TransportAdapterProvider {
  1277. /**
  1278. @@ -24,7 +25,7 @@ trait TransportAdapterProvider {
  1279. }
  1280.  
  1281. class TransportAdapters(system: ExtendedActorSystem) extends Extension {
  1282. - val settings = RARP(system).provider.remoteSettings
  1283. + val settings: RemoteSettings = RARP(system).provider.remoteSettings
  1284.  
  1285. private val adaptersTable: Map[String, TransportAdapterProvider] = for ((name, fqn) ← settings.Adapters) yield {
  1286. name → system.dynamicAccess.createInstanceFor[TransportAdapterProvider](fqn, immutable.Seq.empty).recover({
  1287. @@ -40,7 +41,7 @@ class TransportAdapters(system: ExtendedActorSystem) extends Extension {
  1288.  
  1289. object TransportAdaptersExtension extends ExtensionId[TransportAdapters] with ExtensionIdProvider {
  1290. override def get(system: ActorSystem): TransportAdapters = super.get(system)
  1291. - override def lookup = TransportAdaptersExtension
  1292. + override def lookup: TransportAdaptersExtension.type = TransportAdaptersExtension
  1293. override def createExtension(system: ExtendedActorSystem): TransportAdapters =
  1294. new TransportAdapters(system)
  1295. }
  1296. @@ -131,8 +132,8 @@ abstract class AbstractTransportAdapterHandle(
  1297. wrappedHandle,
  1298. addedSchemeIdentifier)
  1299.  
  1300. - override val localAddress = augmentScheme(originalLocalAddress)
  1301. - override val remoteAddress = augmentScheme(originalRemoteAddress)
  1302. + override val localAddress: Address = augmentScheme(originalLocalAddress)
  1303. + override val remoteAddress: Address = augmentScheme(originalRemoteAddress)
  1304.  
  1305. }
  1306.  
  1307. @@ -147,7 +148,7 @@ object ActorTransportAdapter {
  1308. final case class DisassociateUnderlying(info: DisassociateInfo = AssociationHandle.Unknown)
  1309. extends TransportOperation with DeadLetterSuppression
  1310.  
  1311. - implicit val AskTimeout = Timeout(5.seconds)
  1312. + implicit val AskTimeout: Timeout = Timeout(5.seconds)
  1313. }
  1314.  
  1315. abstract class ActorTransportAdapter(wrappedTransport: Transport, system: ActorSystem)
  1316. diff --git a/akka-remote/src/main/scala/akka/remote/transport/AkkaPduCodec.scala b/akka-remote/src/main/scala/akka/remote/transport/AkkaPduCodec.scala
  1317. index 210dd70855..0951c4d654 100644
  1318. --- a/akka-remote/src/main/scala/akka/remote/transport/AkkaPduCodec.scala
  1319. +++ b/akka-remote/src/main/scala/akka/remote/transport/AkkaPduCodec.scala
  1320. @@ -42,7 +42,7 @@ private[remote] object AkkaPduCodec {
  1321. senderOption: OptionVal[ActorRef],
  1322. seqOption: Option[SeqNo]) extends HasSequenceNumber {
  1323.  
  1324. - def reliableDeliveryEnabled = seqOption.isDefined
  1325. + def reliableDeliveryEnabled: Boolean = seqOption.isDefined
  1326.  
  1327. override def seq: SeqNo = seqOption.get
  1328. }
  1329. diff --git a/akka-remote/src/main/scala/akka/remote/transport/AkkaProtocolTransport.scala b/akka-remote/src/main/scala/akka/remote/transport/AkkaProtocolTransport.scala
  1330. index 6157e4e0be..c167fca550 100644
  1331. --- a/akka-remote/src/main/scala/akka/remote/transport/AkkaProtocolTransport.scala
  1332. +++ b/akka-remote/src/main/scala/akka/remote/transport/AkkaProtocolTransport.scala
  1333. @@ -26,6 +26,7 @@ import scala.concurrent.{ Future, Promise }
  1334. import scala.util.control.NonFatal
  1335. import akka.dispatch.{ RequiresMessageQueue, UnboundedMessageQueueSemantics }
  1336. import akka.event.{ LogMarker, Logging }
  1337. +import java.util.concurrent.atomic.AtomicInteger
  1338.  
  1339. @SerialVersionUID(1L)
  1340. class AkkaProtocolException(msg: String, cause: Throwable) extends AkkaException(msg, cause) with OnlyCauseStackTrace {
  1341. @@ -63,7 +64,7 @@ private[remote] class AkkaProtocolSettings(config: Config) {
  1342. private[remote] object AkkaProtocolTransport { //Couldn't these go into the Remoting Extension/ RemoteSettings instead?
  1343. val AkkaScheme: String = "akka"
  1344. val AkkaOverhead: Int = 0 //Don't know yet
  1345. - val UniqueId = new java.util.concurrent.atomic.AtomicInteger(0)
  1346. + val UniqueId: AtomicInteger = new java.util.concurrent.atomic.AtomicInteger(0)
  1347.  
  1348. final case class AssociateUnderlyingRefuseUid(
  1349. remoteAddress: Address,
  1350. @@ -116,8 +117,8 @@ private[remote] class AkkaProtocolTransport(
  1351. }
  1352.  
  1353. override val maximumOverhead: Int = AkkaProtocolTransport.AkkaOverhead
  1354. - protected def managerName = s"akkaprotocolmanager.${wrappedTransport.schemeIdentifier}${UniqueId.getAndIncrement}"
  1355. - protected def managerProps = {
  1356. + protected def managerName: String = s"akkaprotocolmanager.${wrappedTransport.schemeIdentifier}${UniqueId.getAndIncrement}"
  1357. + protected def managerProps: Props = {
  1358. val wt = wrappedTransport
  1359. val s = settings
  1360. Props(classOf[AkkaProtocolManager], wt, s).withDeploy(Deploy.local)
  1361. @@ -131,7 +132,7 @@ private[transport] class AkkaProtocolManager(
  1362.  
  1363. // The AkkaProtocolTransport does not handle the recovery of associations, this task is implemented in the
  1364. // remoting itself. Hence the strategy Stop.
  1365. - override val supervisorStrategy = OneForOneStrategy() {
  1366. + override val supervisorStrategy: OneForOneStrategy = OneForOneStrategy() {
  1367. case NonFatal(_) ⇒ Stop
  1368. }
  1369.  
  1370. @@ -321,7 +322,7 @@ private[transport] class ProtocolStateActor(
  1371. this(InboundUnassociated(associationListener, wrappedHandle), handshakeInfo, refuseUid = None, settings, codec, failureDetector)
  1372. }
  1373.  
  1374. - val localAddress = localHandshakeInfo.origin
  1375. + val localAddress: Address = localHandshakeInfo.origin
  1376. val handshakeTimerKey = "handshake-timer"
  1377.  
  1378. initialData match {
  1379. diff --git a/akka-remote/src/main/scala/akka/remote/transport/FailureInjectorTransportAdapter.scala b/akka-remote/src/main/scala/akka/remote/transport/FailureInjectorTransportAdapter.scala
  1380. index 01f2096228..4b5f63532e 100644
  1381. --- a/akka-remote/src/main/scala/akka/remote/transport/FailureInjectorTransportAdapter.scala
  1382. +++ b/akka-remote/src/main/scala/akka/remote/transport/FailureInjectorTransportAdapter.scala
  1383. @@ -44,7 +44,7 @@ private[remote] object FailureInjectorTransportAdapter {
  1384. /**
  1385. * Java API: get the singleton instance
  1386. */
  1387. - def getInstance = this
  1388. + def getInstance: PassThru.type = this
  1389. }
  1390. @SerialVersionUID(1L)
  1391. final case class Drop(outboundDropP: Double, inboundDropP: Double) extends GremlinMode
  1392. @@ -64,7 +64,7 @@ private[remote] class FailureInjectorTransportAdapter(wrappedTransport: Transpor
  1393. private[transport] val addressChaosTable = new ConcurrentHashMap[Address, GremlinMode]()
  1394. @volatile private var allMode: GremlinMode = PassThru
  1395.  
  1396. - override val addedSchemeIdentifier = FailureInjectorSchemeIdentifier
  1397. + override val addedSchemeIdentifier: String = FailureInjectorSchemeIdentifier
  1398. protected def maximumOverhead = 0
  1399.  
  1400. override def managementCommand(cmd: Any): Future[Boolean] = cmd match {
  1401. diff --git a/akka-remote/src/main/scala/akka/remote/transport/TestTransport.scala b/akka-remote/src/main/scala/akka/remote/transport/TestTransport.scala
  1402. index 87840a8957..7095647dd7 100644
  1403. --- a/akka-remote/src/main/scala/akka/remote/transport/TestTransport.scala
  1404. +++ b/akka-remote/src/main/scala/akka/remote/transport/TestTransport.scala
  1405. @@ -92,21 +92,21 @@ class TestTransport(
  1406. /**
  1407. * The [[akka.remote.transport.TestTransport.SwitchableLoggedBehavior]] for the listen() method.
  1408. */
  1409. - val listenBehavior = new SwitchableLoggedBehavior[Unit, (Address, Promise[AssociationEventListener])](
  1410. + val listenBehavior: SwitchableLoggedBehavior[Unit, (Address, Promise[AssociationEventListener])] = new SwitchableLoggedBehavior[Unit, (Address, Promise[AssociationEventListener])](
  1411. (_) ⇒ defaultListen,
  1412. (_) ⇒ registry.logActivity(ListenAttempt(localAddress)))
  1413.  
  1414. /**
  1415. * The [[akka.remote.transport.TestTransport.SwitchableLoggedBehavior]] for the associate() method.
  1416. */
  1417. - val associateBehavior = new SwitchableLoggedBehavior[Address, AssociationHandle](
  1418. + val associateBehavior: SwitchableLoggedBehavior[Address, AssociationHandle] = new SwitchableLoggedBehavior[Address, AssociationHandle](
  1419. defaultAssociate _,
  1420. (remoteAddress) ⇒ registry.logActivity(AssociateAttempt(localAddress, remoteAddress)))
  1421.  
  1422. /**
  1423. * The [[akka.remote.transport.TestTransport.SwitchableLoggedBehavior]] for the shutdown() method.
  1424. */
  1425. - val shutdownBehavior = new SwitchableLoggedBehavior[Unit, Boolean](
  1426. + val shutdownBehavior: SwitchableLoggedBehavior[Unit, Boolean] = new SwitchableLoggedBehavior[Unit, Boolean](
  1427. (_) ⇒ defaultShutdown,
  1428. (_) ⇒ registry.logActivity(ShutdownAttempt(localAddress)))
  1429.  
  1430. @@ -139,7 +139,7 @@ class TestTransport(
  1431. * altering the behavior via pushDelayed will turn write to a blocking operation -- use of pushDelayed therefore
  1432. * is not recommended.
  1433. */
  1434. - val writeBehavior = new SwitchableLoggedBehavior[(TestAssociationHandle, ByteString), Boolean](
  1435. + val writeBehavior: SwitchableLoggedBehavior[(TestAssociationHandle, ByteString), Boolean] = new SwitchableLoggedBehavior[(TestAssociationHandle, ByteString), Boolean](
  1436. defaultBehavior = {
  1437. defaultWrite _
  1438. },
  1439. @@ -152,7 +152,7 @@ class TestTransport(
  1440. * The [[akka.remote.transport.TestTransport.SwitchableLoggedBehavior]] for the disassociate() method on handles. All
  1441. * handle calls pass through this call.
  1442. */
  1443. - val disassociateBehavior = new SwitchableLoggedBehavior[TestAssociationHandle, Unit](
  1444. + val disassociateBehavior: SwitchableLoggedBehavior[TestAssociationHandle, Unit] = new SwitchableLoggedBehavior[TestAssociationHandle, Unit](
  1445. defaultBehavior = {
  1446. defaultDisassociate _
  1447. },
  1448. @@ -467,5 +467,5 @@ final case class TestAssociationHandle(
  1449. * Key used in [[akka.remote.transport.TestTransport.AssociationRegistry]] to identify associations. Contains an
  1450. * ordered pair of addresses, where the first element of the pair is always the initiator of the association.
  1451. */
  1452. - val key = if (!inbound) (localAddress, remoteAddress) else (remoteAddress, localAddress)
  1453. + val key: (Address, Address) = if (!inbound) (localAddress, remoteAddress) else (remoteAddress, localAddress)
  1454. }
  1455. diff --git a/akka-remote/src/main/scala/akka/remote/transport/ThrottlerTransportAdapter.scala b/akka-remote/src/main/scala/akka/remote/transport/ThrottlerTransportAdapter.scala
  1456. index 7697a26a50..94c7016587 100644
  1457. --- a/akka-remote/src/main/scala/akka/remote/transport/ThrottlerTransportAdapter.scala
  1458. +++ b/akka-remote/src/main/scala/akka/remote/transport/ThrottlerTransportAdapter.scala
  1459. @@ -26,6 +26,7 @@ import akka.dispatch.sysmsg.{ Unwatch, Watch }
  1460. import akka.dispatch.{ RequiresMessageQueue, UnboundedMessageQueueSemantics }
  1461. import akka.event.LoggingAdapter
  1462. import akka.remote.RARP
  1463. +import java.util.concurrent.atomic.AtomicInteger
  1464.  
  1465. class ThrottlerProvider extends TransportAdapterProvider {
  1466.  
  1467. @@ -36,7 +37,7 @@ class ThrottlerProvider extends TransportAdapterProvider {
  1468.  
  1469. object ThrottlerTransportAdapter {
  1470. val SchemeIdentifier = "trttl"
  1471. - val UniqueId = new java.util.concurrent.atomic.AtomicInteger(0)
  1472. + val UniqueId: AtomicInteger = new java.util.concurrent.atomic.AtomicInteger(0)
  1473.  
  1474. sealed trait Direction {
  1475. def includes(other: Direction): Boolean
  1476. @@ -54,7 +55,7 @@ object ThrottlerTransportAdapter {
  1477. /**
  1478. * Java API: get the singleton instance
  1479. */
  1480. - def getInstance = this
  1481. + def getInstance: Send.type = this
  1482. }
  1483.  
  1484. @SerialVersionUID(1L)
  1485. @@ -67,7 +68,7 @@ object ThrottlerTransportAdapter {
  1486. /**
  1487. * Java API: get the singleton instance
  1488. */
  1489. - def getInstance = this
  1490. + def getInstance: Receive.type = this
  1491. }
  1492.  
  1493. @SerialVersionUID(1L)
  1494. @@ -77,7 +78,7 @@ object ThrottlerTransportAdapter {
  1495. /**
  1496. * Java API: get the singleton instance
  1497. */
  1498. - def getInstance = this
  1499. + def getInstance: Both.type = this
  1500. }
  1501. }
  1502.  
  1503. @@ -89,7 +90,7 @@ object ThrottlerTransportAdapter {
  1504. /**
  1505. * Java API: get the singleton instance
  1506. */
  1507. - def getInstance = this
  1508. + def getInstance: SetThrottleAck.type = this
  1509. }
  1510.  
  1511. sealed trait ThrottleMode extends NoSerializationVerificationNeeded {
  1512. @@ -131,7 +132,7 @@ object ThrottlerTransportAdapter {
  1513. /**
  1514. * Java API: get the singleton instance
  1515. */
  1516. - def getInstance = this
  1517. + def getInstance: Unthrottled.type = this
  1518.  
  1519. }
  1520.  
  1521. @@ -143,7 +144,7 @@ object ThrottlerTransportAdapter {
  1522. /**
  1523. * Java API: get the singleton instance
  1524. */
  1525. - def getInstance = this
  1526. + def getInstance: Blackhole.type = this
  1527. }
  1528.  
  1529. /**
  1530. @@ -163,13 +164,13 @@ object ThrottlerTransportAdapter {
  1531. /**
  1532. * Java API: get the singleton instance
  1533. */
  1534. - def getInstance = this
  1535. + def getInstance: ForceDisassociateAck.type = this
  1536. }
  1537. }
  1538.  
  1539. class ThrottlerTransportAdapter(_wrappedTransport: Transport, _system: ExtendedActorSystem) extends ActorTransportAdapter(_wrappedTransport, _system) {
  1540.  
  1541. - override protected def addedSchemeIdentifier = SchemeIdentifier
  1542. + override protected def addedSchemeIdentifier: String = SchemeIdentifier
  1543. override protected def maximumOverhead = 0
  1544. protected def managerName: String = s"throttlermanager.${wrappedTransport.schemeIdentifier}${UniqueId.getAndIncrement}"
  1545. protected def managerProps: Props = {
  1546. @@ -373,7 +374,7 @@ private[transport] class ThrottledAssociation(
  1547. import context.dispatcher
  1548.  
  1549. var inboundThrottleMode: ThrottleMode = _
  1550. - var throttledMessages = Queue.empty[ByteString]
  1551. + var throttledMessages: Queue[ByteString] = Queue.empty[ByteString]
  1552. var upstreamListener: HandleEventListener = _
  1553.  
  1554. override def postStop(): Unit = originalHandle.disassociate("the owning ThrottledAssociation stopped", log)
  1555. diff --git a/akka-remote/src/main/scala/akka/remote/transport/netty/NettySSLSupport.scala b/akka-remote/src/main/scala/akka/remote/transport/netty/NettySSLSupport.scala
  1556. index 3ac8d5ec9b..f0a0a9e2cd 100644
  1557. --- a/akka-remote/src/main/scala/akka/remote/transport/netty/NettySSLSupport.scala
  1558. +++ b/akka-remote/src/main/scala/akka/remote/transport/netty/NettySSLSupport.scala
  1559. @@ -27,20 +27,20 @@ import java.nio.file.Paths
  1560. private[akka] class SSLSettings(config: Config) {
  1561. import config.{ getBoolean, getString, getStringList }
  1562.  
  1563. - val SSLKeyStore = getString("key-store")
  1564. - val SSLTrustStore = getString("trust-store")
  1565. - val SSLKeyStorePassword = getString("key-store-password")
  1566. - val SSLKeyPassword = getString("key-password")
  1567. + val SSLKeyStore: String = getString("key-store")
  1568. + val SSLTrustStore: String = getString("trust-store")
  1569. + val SSLKeyStorePassword: String = getString("key-store-password")
  1570. + val SSLKeyPassword: String = getString("key-password")
  1571.  
  1572. - val SSLTrustStorePassword = getString("trust-store-password")
  1573. + val SSLTrustStorePassword: String = getString("trust-store-password")
  1574.  
  1575. - val SSLEnabledAlgorithms = immutableSeq(getStringList("enabled-algorithms")).to[Set]
  1576. + val SSLEnabledAlgorithms: Set[String] = immutableSeq(getStringList("enabled-algorithms")).to[Set]
  1577.  
  1578. - val SSLProtocol = getString("protocol")
  1579. + val SSLProtocol: String = getString("protocol")
  1580.  
  1581. - val SSLRandomNumberGenerator = getString("random-number-generator")
  1582. + val SSLRandomNumberGenerator: String = getString("random-number-generator")
  1583.  
  1584. - val SSLRequireMutualAuthentication = getBoolean("require-mutual-authentication")
  1585. + val SSLRequireMutualAuthentication: Boolean = getBoolean("require-mutual-authentication")
  1586.  
  1587. private val sslContext = new AtomicReference[SSLContext]()
  1588. @tailrec final def getOrCreateContext(log: MarkerLoggingAdapter): SSLContext =
  1589. diff --git a/akka-stream/src/main/scala/akka/stream/ActorMaterializer.scala b/akka-stream/src/main/scala/akka/stream/ActorMaterializer.scala
  1590. index bcd25edfe3..b905d0a686 100644
  1591. --- a/akka-stream/src/main/scala/akka/stream/ActorMaterializer.scala
  1592. +++ b/akka-stream/src/main/scala/akka/stream/ActorMaterializer.scala
  1593. @@ -243,7 +243,7 @@ object ActorMaterializerSettings {
  1594. outputBurstLimit: Int,
  1595. fuzzingMode: Boolean,
  1596. autoFusing: Boolean,
  1597. - maxFixedBufferSize: Int) =
  1598. + maxFixedBufferSize: Int): ActorMaterializerSettings =
  1599. new ActorMaterializerSettings(
  1600. initialInputBufferSize, maxInputBufferSize, dispatcher, supervisionDecider, subscriptionTimeoutSettings, debugLogging,
  1601. outputBurstLimit, fuzzingMode, autoFusing, maxFixedBufferSize)
  1602. @@ -285,7 +285,7 @@ object ActorMaterializerSettings {
  1603. outputBurstLimit: Int,
  1604. fuzzingMode: Boolean,
  1605. autoFusing: Boolean,
  1606. - maxFixedBufferSize: Int) =
  1607. + maxFixedBufferSize: Int): ActorMaterializerSettings =
  1608. new ActorMaterializerSettings(
  1609. initialInputBufferSize, maxInputBufferSize, dispatcher, supervisionDecider, subscriptionTimeoutSettings, debugLogging,
  1610. outputBurstLimit, fuzzingMode, autoFusing, maxFixedBufferSize)
  1611. @@ -538,10 +538,10 @@ object IOSettings {
  1612. new IOSettings(tcpWriteBufferSize)
  1613.  
  1614. /** Java API */
  1615. - def create(config: Config) = apply(config)
  1616. + def create(config: Config): IOSettings = apply(config)
  1617.  
  1618. /** Java API */
  1619. - def create(system: ActorSystem) = apply(system)
  1620. + def create(system: ActorSystem): IOSettings = apply(system)
  1621.  
  1622. /** Java API */
  1623. def create(tcpWriteBufferSize: Int): IOSettings =
  1624. @@ -560,7 +560,7 @@ final class IOSettings private (val tcpWriteBufferSize: Int) {
  1625. case _ ⇒ false
  1626. }
  1627.  
  1628. - override def toString =
  1629. + override def toString: String =
  1630. s"""IoSettings(${tcpWriteBufferSize})"""
  1631. }
  1632.  
  1633. diff --git a/akka-stream/src/main/scala/akka/stream/Attributes.scala b/akka-stream/src/main/scala/akka/stream/Attributes.scala
  1634. index c9d57c04ae..3135c3fd3f 100644
  1635. --- a/akka-stream/src/main/scala/akka/stream/Attributes.scala
  1636. +++ b/akka-stream/src/main/scala/akka/stream/Attributes.scala
  1637. @@ -331,7 +331,7 @@ object Attributes {
  1638. * Passing in null as any of the arguments sets the level to its default value, which is:
  1639. * `Debug` for `onElement` and `onFinish`, and `Error` for `onFailure`.
  1640. */
  1641. - def createLogLevels(onElement: Logging.LogLevel, onFinish: Logging.LogLevel, onFailure: Logging.LogLevel) =
  1642. + def createLogLevels(onElement: Logging.LogLevel, onFinish: Logging.LogLevel, onFailure: Logging.LogLevel): Attributes =
  1643. logLevels(
  1644. onElement = Option(onElement).getOrElse(Logging.DebugLevel),
  1645. onFinish = Option(onFinish).getOrElse(Logging.DebugLevel),
  1646. @@ -343,7 +343,7 @@ object Attributes {
  1647. *
  1648. * See [[Attributes.createLogLevels]] for Java API
  1649. */
  1650. - def logLevels(onElement: Logging.LogLevel = Logging.DebugLevel, onFinish: Logging.LogLevel = Logging.DebugLevel, onFailure: Logging.LogLevel = Logging.ErrorLevel) =
  1651. + def logLevels(onElement: Logging.LogLevel = Logging.DebugLevel, onFinish: Logging.LogLevel = Logging.DebugLevel, onFailure: Logging.LogLevel = Logging.ErrorLevel): Attributes =
  1652. Attributes(LogLevels(onElement, onFinish, onFailure))
  1653.  
  1654. /**
  1655. @@ -398,7 +398,7 @@ object ActorAttributes {
  1656. * Passing in null as any of the arguments sets the level to its default value, which is:
  1657. * `Debug` for `onElement` and `onFinish`, and `Error` for `onFailure`.
  1658. */
  1659. - def createLogLevels(onElement: Logging.LogLevel, onFinish: Logging.LogLevel, onFailure: Logging.LogLevel) =
  1660. + def createLogLevels(onElement: Logging.LogLevel, onFinish: Logging.LogLevel, onFailure: Logging.LogLevel): Attributes =
  1661. logLevels(
  1662. onElement = Option(onElement).getOrElse(Logging.DebugLevel),
  1663. onFinish = Option(onFinish).getOrElse(Logging.DebugLevel),
  1664. @@ -410,7 +410,7 @@ object ActorAttributes {
  1665. *
  1666. * See [[Attributes.createLogLevels]] for Java API
  1667. */
  1668. - def logLevels(onElement: Logging.LogLevel = Logging.DebugLevel, onFinish: Logging.LogLevel = Logging.DebugLevel, onFailure: Logging.LogLevel = Logging.ErrorLevel) =
  1669. + def logLevels(onElement: Logging.LogLevel = Logging.DebugLevel, onFinish: Logging.LogLevel = Logging.DebugLevel, onFailure: Logging.LogLevel = Logging.ErrorLevel): Attributes =
  1670. Attributes(LogLevels(onElement, onFinish, onFailure))
  1671.  
  1672. }
  1673. diff --git a/akka-stream/src/main/scala/akka/stream/FlowMonitor.scala b/akka-stream/src/main/scala/akka/stream/FlowMonitor.scala
  1674. index 73dc0943f9..1481d1290b 100644
  1675. --- a/akka-stream/src/main/scala/akka/stream/FlowMonitor.scala
  1676. +++ b/akka-stream/src/main/scala/akka/stream/FlowMonitor.scala
  1677. @@ -59,5 +59,5 @@ object FlowMonitorState {
  1678. /**
  1679. * Java API
  1680. */
  1681. - def finished[U]() = Finished
  1682. + def finished[U](): Finished.type = Finished
  1683. }
  1684. diff --git a/akka-stream/src/main/scala/akka/stream/Graph.scala b/akka-stream/src/main/scala/akka/stream/Graph.scala
  1685. index 1d1f5f32d6..57c45d410d 100644
  1686. --- a/akka-stream/src/main/scala/akka/stream/Graph.scala
  1687. +++ b/akka-stream/src/main/scala/akka/stream/Graph.scala
  1688. @@ -42,7 +42,7 @@ trait Graph[+S <: Shape, +M] {
  1689. *
  1690. * @param dispatcher Run the graph on this dispatcher
  1691. */
  1692. - def async(dispatcher: String) =
  1693. + def async(dispatcher: String): Graph[S, M] =
  1694. addAttributes(
  1695. Attributes.asyncBoundary and ActorAttributes.dispatcher(dispatcher)
  1696. )
  1697. @@ -53,7 +53,7 @@ trait Graph[+S <: Shape, +M] {
  1698. * @param dispatcher Run the graph on this dispatcher
  1699. * @param inputBufferSize Set the input buffer to this size for the graph
  1700. */
  1701. - def async(dispatcher: String, inputBufferSize: Int) =
  1702. + def async(dispatcher: String, inputBufferSize: Int): Graph[S, M] =
  1703. addAttributes(
  1704. Attributes.asyncBoundary and ActorAttributes.dispatcher(dispatcher)
  1705. and Attributes.inputBuffer(inputBufferSize, inputBufferSize)
  1706. diff --git a/akka-stream/src/main/scala/akka/stream/KillSwitch.scala b/akka-stream/src/main/scala/akka/stream/KillSwitch.scala
  1707. index 4006f5a111..bbf1975265 100644
  1708. --- a/akka-stream/src/main/scala/akka/stream/KillSwitch.scala
  1709. +++ b/akka-stream/src/main/scala/akka/stream/KillSwitch.scala
  1710. @@ -69,11 +69,11 @@ object KillSwitches {
  1711. }
  1712.  
  1713. private[stream] object UniqueKillSwitchStage extends GraphStageWithMaterializedValue[FlowShape[Any, Any], UniqueKillSwitch] {
  1714. - override val initialAttributes = Attributes.name("breaker")
  1715. - override val shape = FlowShape(Inlet[Any]("KillSwitch.in"), Outlet[Any]("KillSwitch.out"))
  1716. + override val initialAttributes: Attributes = Attributes.name("breaker")
  1717. + override val shape: FlowShape[Any, Any] = FlowShape(Inlet[Any]("KillSwitch.in"), Outlet[Any]("KillSwitch.out"))
  1718. override def toString: String = "UniqueKillSwitchFlow"
  1719.  
  1720. - override def createLogicAndMaterializedValue(attr: Attributes) = {
  1721. + override def createLogicAndMaterializedValue(attr: Attributes): (KillableGraphStageLogic with InHandler with OutHandler, UniqueKillSwitch) = {
  1722. val promise = Promise[Done]
  1723. val switch = new UniqueKillSwitch(promise)
  1724.  
  1725. @@ -90,13 +90,13 @@ object KillSwitches {
  1726.  
  1727. private[stream] object UniqueBidiKillSwitchStage extends GraphStageWithMaterializedValue[BidiShape[Any, Any, Any, Any], UniqueKillSwitch] {
  1728.  
  1729. - override val initialAttributes = Attributes.name("breaker")
  1730. - override val shape = BidiShape(
  1731. + override val initialAttributes: Attributes = Attributes.name("breaker")
  1732. + override val shape: BidiShape[Any, Any, Any, Any] = BidiShape(
  1733. Inlet[Any]("KillSwitchBidi.in1"), Outlet[Any]("KillSwitchBidi.out1"),
  1734. Inlet[Any]("KillSwitchBidi.in2"), Outlet[Any]("KillSwitchBidi.out2"))
  1735. override def toString: String = "UniqueKillSwitchBidi"
  1736.  
  1737. - override def createLogicAndMaterializedValue(attr: Attributes) = {
  1738. + override def createLogicAndMaterializedValue(attr: Attributes): (KillableGraphStageLogic, UniqueKillSwitch) = {
  1739. val promise = Promise[Done]
  1740. val switch = new UniqueKillSwitch(promise)
  1741.  
  1742. diff --git a/akka-stream/src/main/scala/akka/stream/Shape.scala b/akka-stream/src/main/scala/akka/stream/Shape.scala
  1743. index fe2fc8612b..78ce1bb3d3 100644
  1744. --- a/akka-stream/src/main/scala/akka/stream/Shape.scala
  1745. +++ b/akka-stream/src/main/scala/akka/stream/Shape.scala
  1746. @@ -243,7 +243,7 @@ sealed abstract class ClosedShape extends Shape
  1747. object ClosedShape extends ClosedShape {
  1748. override val inlets: immutable.Seq[Inlet[_]] = EmptyImmutableSeq
  1749. override val outlets: immutable.Seq[Outlet[_]] = EmptyImmutableSeq
  1750. - override def deepCopy() = this
  1751. + override def deepCopy(): ClosedShape.type = this
  1752.  
  1753. /**
  1754. * Java API: obtain ClosedShape instance
  1755. @@ -260,7 +260,7 @@ object ClosedShape extends ClosedShape {
  1756. * meaningful type of Shape when the building is finished.
  1757. */
  1758. case class AmorphousShape(inlets: immutable.Seq[Inlet[_]], outlets: immutable.Seq[Outlet[_]]) extends Shape {
  1759. - override def deepCopy() = AmorphousShape(inlets.map(_.carbonCopy()), outlets.map(_.carbonCopy()))
  1760. + override def deepCopy(): AmorphousShape = AmorphousShape(inlets.map(_.carbonCopy()), outlets.map(_.carbonCopy()))
  1761. }
  1762.  
  1763. /**
  1764. diff --git a/akka-stream/src/main/scala/akka/stream/Supervision.scala b/akka-stream/src/main/scala/akka/stream/Supervision.scala
  1765. index 9d3dd1735b..f1b1e4c20e 100644
  1766. --- a/akka-stream/src/main/scala/akka/stream/Supervision.scala
  1767. +++ b/akka-stream/src/main/scala/akka/stream/Supervision.scala
  1768. @@ -18,7 +18,7 @@ object Supervision {
  1769. * Java API: The stream will be completed with failure if application code for processing an element
  1770. * throws an exception.
  1771. */
  1772. - def stop = Stop
  1773. + def stop: Stop.type = Stop
  1774.  
  1775. /**
  1776. * Scala API: The element is dropped and the stream continues if application code for processing
  1777. @@ -30,7 +30,7 @@ object Supervision {
  1778. * Java API: The element is dropped and the stream continues if application code for processing
  1779. * an element throws an exception.
  1780. */
  1781. - def resume = Resume
  1782. + def resume: Resume.type = Resume
  1783.  
  1784. /**
  1785. * Scala API: The element is dropped and the stream continues after restarting the stage
  1786. @@ -46,7 +46,7 @@ object Supervision {
  1787. * Restarting a stage means that any accumulated state is cleared. This is typically
  1788. * performed by creating a new instance of the stage.
  1789. */
  1790. - def restart = Restart
  1791. + def restart: Restart.type = Restart
  1792.  
  1793. type Decider = Function[Throwable, Directive]
  1794.  
  1795. @@ -55,7 +55,7 @@ object Supervision {
  1796. */
  1797. val stoppingDecider: Decider with japi.Function[Throwable, Directive] =
  1798. new Decider with japi.Function[Throwable, Directive] {
  1799. - override def apply(e: Throwable) = Stop
  1800. + override def apply(e: Throwable): Stop.type = Stop
  1801. }
  1802.  
  1803. /**
  1804. @@ -68,7 +68,7 @@ object Supervision {
  1805. */
  1806. val resumingDecider: Decider with japi.Function[Throwable, Directive] =
  1807. new Decider with japi.Function[Throwable, Directive] {
  1808. - override def apply(e: Throwable) = Resume
  1809. + override def apply(e: Throwable): Resume.type = Resume
  1810. }
  1811.  
  1812. /**
  1813. @@ -81,7 +81,7 @@ object Supervision {
  1814. */
  1815. val restartingDecider: Decider with japi.Function[Throwable, Directive] =
  1816. new Decider with japi.Function[Throwable, Directive] {
  1817. - override def apply(e: Throwable) = Restart
  1818. + override def apply(e: Throwable): Restart.type = Restart
  1819. }
  1820.  
  1821. /**
  1822. diff --git a/akka-stream/src/main/scala/akka/stream/ThrottleMode.scala b/akka-stream/src/main/scala/akka/stream/ThrottleMode.scala
  1823. index f4ff684e95..423d296cea 100644
  1824. --- a/akka-stream/src/main/scala/akka/stream/ThrottleMode.scala
  1825. +++ b/akka-stream/src/main/scala/akka/stream/ThrottleMode.scala
  1826. @@ -23,12 +23,12 @@ object ThrottleMode {
  1827. /**
  1828. * Java API: Tells throttle to make pauses before emitting messages to meet throttle rate
  1829. */
  1830. - def shaping = Shaping
  1831. + def shaping: Shaping.type = Shaping
  1832.  
  1833. /**
  1834. * Java API: Makes throttle fail with exception when upstream is faster than throttle rate
  1835. */
  1836. - def enforcing = Enforcing
  1837. + def enforcing: Enforcing.type = Enforcing
  1838. }
  1839.  
  1840. /**
  1841. diff --git a/akka-stream/src/main/scala/akka/stream/actor/ActorPublisher.scala b/akka-stream/src/main/scala/akka/stream/actor/ActorPublisher.scala
  1842. index 822891cc21..f9ff1cfc3c 100644
  1843. --- a/akka-stream/src/main/scala/akka/stream/actor/ActorPublisher.scala
  1844. +++ b/akka-stream/src/main/scala/akka/stream/actor/ActorPublisher.scala
  1845. @@ -68,7 +68,7 @@ object ActorPublisherMessage {
  1846. /**
  1847. * Java API: get the singleton instance of the `Cancel` message
  1848. */
  1849. - def cancelInstance = Cancel
  1850. + def cancelInstance: Cancel.type = Cancel
  1851.  
  1852. /**
  1853. * This message is delivered to the [[ActorPublisher]] actor in order to signal the exceeding of an subscription timeout.
  1854. @@ -79,7 +79,7 @@ object ActorPublisherMessage {
  1855. /**
  1856. * Java API: get the singleton instance of the `SubscriptionTimeoutExceeded` message
  1857. */
  1858. - def subscriptionTimeoutExceededInstance = SubscriptionTimeoutExceeded
  1859. + def subscriptionTimeoutExceededInstance: SubscriptionTimeoutExceeded.type = SubscriptionTimeoutExceeded
  1860. }
  1861.  
  1862. /**
  1863. @@ -415,7 +415,7 @@ private[akka] object ActorPublisherState extends ExtensionId[ActorPublisherState
  1864.  
  1865. override def get(system: ActorSystem): ActorPublisherState = super.get(system)
  1866.  
  1867. - override def lookup() = ActorPublisherState
  1868. + override def lookup(): ActorPublisherState.type = ActorPublisherState
  1869.  
  1870. override def createExtension(system: ExtendedActorSystem): ActorPublisherState =
  1871. new ActorPublisherState
  1872. diff --git a/akka-stream/src/main/scala/akka/stream/actor/ActorSubscriber.scala b/akka-stream/src/main/scala/akka/stream/actor/ActorSubscriber.scala
  1873. index 8d346cd7b6..4b5f85ba56 100644
  1874. --- a/akka-stream/src/main/scala/akka/stream/actor/ActorSubscriber.scala
  1875. +++ b/akka-stream/src/main/scala/akka/stream/actor/ActorSubscriber.scala
  1876. @@ -34,7 +34,7 @@ object ActorSubscriberMessage {
  1877. /**
  1878. * Java API: get the singleton instance of the `OnComplete` message
  1879. */
  1880. - def onCompleteInstance = OnComplete
  1881. + def onCompleteInstance: OnComplete.type = OnComplete
  1882. }
  1883.  
  1884. /**
  1885. @@ -64,7 +64,7 @@ case object OneByOneRequestStrategy extends RequestStrategy {
  1886. /**
  1887. * Java API: get the singleton instance
  1888. */
  1889. - def getInstance = this
  1890. + def getInstance: OneByOneRequestStrategy.type = this
  1891. }
  1892.  
  1893. /**
  1894. @@ -77,7 +77,7 @@ case object ZeroRequestStrategy extends RequestStrategy {
  1895. /**
  1896. * Java API: get the singleton instance
  1897. */
  1898. - def getInstance = this
  1899. + def getInstance: ZeroRequestStrategy.type = this
  1900. }
  1901.  
  1902. object WatermarkRequestStrategy {
  1903. @@ -313,7 +313,7 @@ private[akka] final class ActorSubscriberImpl[T](val impl: ActorRef) extends Sub
  1904. private[akka] object ActorSubscriberState extends ExtensionId[ActorSubscriberState] with ExtensionIdProvider {
  1905. override def get(system: ActorSystem): ActorSubscriberState = super.get(system)
  1906.  
  1907. - override def lookup() = ActorSubscriberState
  1908. + override def lookup(): ActorSubscriberState.type = ActorSubscriberState
  1909.  
  1910. override def createExtension(system: ExtendedActorSystem): ActorSubscriberState =
  1911. new ActorSubscriberState
  1912. diff --git a/akka-stream/src/main/scala/akka/stream/impl/ActorMaterializerImpl.scala b/akka-stream/src/main/scala/akka/stream/impl/ActorMaterializerImpl.scala
  1913. index d351beae6d..f64dcce891 100644
  1914. --- a/akka-stream/src/main/scala/akka/stream/impl/ActorMaterializerImpl.scala
  1915. +++ b/akka-stream/src/main/scala/akka/stream/impl/ActorMaterializerImpl.scala
  1916. @@ -91,7 +91,7 @@ import scala.concurrent.{ Await, ExecutionContextExecutor }
  1917. * The default phases are left in-tact since we still respect `.async` and other tags that were marked within a sub-fused graph.
  1918. */
  1919. private[akka] class SubFusingActorMaterializerImpl(val delegate: ExtendedActorMaterializer, registerShell: GraphInterpreterShell ⇒ ActorRef) extends Materializer {
  1920. - val subFusingPhase = new Phase[Any] {
  1921. + val subFusingPhase: Phase[Any] = new Phase[Any] {
  1922. override def apply(settings: ActorMaterializerSettings, attributes: Attributes,
  1923. materializer: PhasedFusingActorMaterializer, islandName: String): PhaseIsland[Any] = {
  1924. new GraphStageIsland(settings, attributes, materializer, islandName, OptionVal(registerShell)).asInstanceOf[PhaseIsland[Any]]
  1925. @@ -131,7 +131,7 @@ private[akka] class SubFusingActorMaterializerImpl(val delegate: ExtendedActorMa
  1926. */
  1927. @InternalApi private[akka] object FlowNames extends ExtensionId[FlowNames] with ExtensionIdProvider {
  1928. override def get(system: ActorSystem): FlowNames = super.get(system)
  1929. - override def lookup() = FlowNames
  1930. + override def lookup(): FlowNames.type = FlowNames
  1931. override def createExtension(system: ExtendedActorSystem): FlowNames = new FlowNames
  1932. }
  1933.  
  1934. @@ -139,7 +139,7 @@ private[akka] class SubFusingActorMaterializerImpl(val delegate: ExtendedActorMa
  1935. * INTERNAL API
  1936. */
  1937. @InternalApi private[akka] class FlowNames extends Extension {
  1938. - val name = SeqActorName("Flow")
  1939. + val name: SeqActorNameImpl = SeqActorName("Flow")
  1940. }
  1941.  
  1942. /**
  1943. @@ -173,9 +173,9 @@ private[akka] class SubFusingActorMaterializerImpl(val delegate: ExtendedActorMa
  1944. @InternalApi private[akka] class StreamSupervisor(settings: ActorMaterializerSettings, haveShutDown: AtomicBoolean) extends Actor {
  1945. import akka.stream.impl.StreamSupervisor._
  1946.  
  1947. - override def supervisorStrategy = SupervisorStrategy.stoppingStrategy
  1948. + override def supervisorStrategy: SupervisorStrategy = SupervisorStrategy.stoppingStrategy
  1949.  
  1950. - def receive = {
  1951. + def receive: PartialFunction[Any, Unit] = {
  1952. case Materialize(props, name) ⇒
  1953. val impl = context.actorOf(props, name)
  1954. sender() ! impl
  1955. diff --git a/akka-stream/src/main/scala/akka/stream/impl/ActorProcessor.scala b/akka-stream/src/main/scala/akka/stream/impl/ActorProcessor.scala
  1956. index d8c9cf5bf2..97018dee74 100644
  1957. --- a/akka-stream/src/main/scala/akka/stream/impl/ActorProcessor.scala
  1958. +++ b/akka-stream/src/main/scala/akka/stream/impl/ActorProcessor.scala
  1959. @@ -106,8 +106,8 @@ import akka.event.Logging
  1960. inputBufferElements = 0
  1961. }
  1962.  
  1963. - override def inputsDepleted = upstreamCompleted && inputBufferElements == 0
  1964. - override def inputsAvailable = inputBufferElements > 0
  1965. + override def inputsDepleted: Boolean = upstreamCompleted && inputBufferElements == 0
  1966. + override def inputsAvailable: Boolean = inputBufferElements > 0
  1967.  
  1968. protected def onComplete(): Unit = {
  1969. upstreamCompleted = true
  1970. @@ -167,13 +167,13 @@ import akka.event.Logging
  1971. protected var subscriber: Subscriber[Any] = _
  1972. protected var downstreamDemand: Long = 0L
  1973. protected var downstreamCompleted = false
  1974. - override def demandAvailable = downstreamDemand > 0
  1975. + override def demandAvailable: Boolean = downstreamDemand > 0
  1976. override def demandCount: Long = downstreamDemand
  1977.  
  1978. - override def subreceive = _subreceive
  1979. + override def subreceive: SubReceive = _subreceive
  1980. private val _subreceive = new SubReceive(waitingExposedPublisher)
  1981.  
  1982. - def isSubscribed = subscriber ne null
  1983. + def isSubscribed: Boolean = subscriber ne null
  1984.  
  1985. def enqueueOutputElement(elem: Any): Unit = {
  1986. ReactiveStreamsCompliance.requireNonNullElement(elem)
  1987. @@ -265,7 +265,7 @@ import akka.event.Logging
  1988. /**
  1989. * Subclass may override [[#activeReceive]]
  1990. */
  1991. - final override def receive = new ExposedPublisherReceive(activeReceive, unhandled) {
  1992. + final override def receive: ExposedPublisherReceive = new ExposedPublisherReceive(activeReceive, unhandled) {
  1993. override def receiveExposedPublisher(ep: ExposedPublisher): Unit = {
  1994. primaryOutputs.subreceive(ep)
  1995. context become activeReceive
  1996. diff --git a/akka-stream/src/main/scala/akka/stream/impl/ActorRefBackpressureSinkStage.scala b/akka-stream/src/main/scala/akka/stream/impl/ActorRefBackpressureSinkStage.scala
  1997. index bd8fd86594..1ed20a8d20 100644
  1998. --- a/akka-stream/src/main/scala/akka/stream/impl/ActorRefBackpressureSinkStage.scala
  1999. +++ b/akka-stream/src/main/scala/akka/stream/impl/ActorRefBackpressureSinkStage.scala
  2000. @@ -21,14 +21,14 @@ import akka.stream.stage._
  2001. onFailureMessage: (Throwable) ⇒ Any)
  2002. extends GraphStage[SinkShape[In]] {
  2003. val in: Inlet[In] = Inlet[In]("ActorRefBackpressureSink.in")
  2004. - override def initialAttributes = DefaultAttributes.actorRefWithAck
  2005. + override def initialAttributes: Attributes = DefaultAttributes.actorRefWithAck
  2006. override val shape: SinkShape[In] = SinkShape(in)
  2007.  
  2008. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  2009. new GraphStageLogic(shape) with InHandler {
  2010. implicit def self: ActorRef = stageActor.ref
  2011.  
  2012. - val maxBuffer = inheritedAttributes.getAttribute(classOf[InputBuffer], InputBuffer(16, 16)).max
  2013. + val maxBuffer: Int = inheritedAttributes.getAttribute(classOf[InputBuffer], InputBuffer(16, 16)).max
  2014. require(maxBuffer > 0, "Buffer size must be greater than 0")
  2015.  
  2016. val buffer: util.Deque[In] = new util.ArrayDeque[In]()
  2017. @@ -52,7 +52,7 @@ import akka.stream.stage._
  2018. }
  2019. }
  2020.  
  2021. - override def preStart() = {
  2022. + override def preStart(): Unit = {
  2023. setKeepGoing(true)
  2024. getStageActor(receive).watch(ref)
  2025. ref ! onInitMessage
  2026. diff --git a/akka-stream/src/main/scala/akka/stream/impl/ActorRefSinkActor.scala b/akka-stream/src/main/scala/akka/stream/impl/ActorRefSinkActor.scala
  2027. index 6859d7dd5a..9e1ffe4fc6 100644
  2028. --- a/akka-stream/src/main/scala/akka/stream/impl/ActorRefSinkActor.scala
  2029. +++ b/akka-stream/src/main/scala/akka/stream/impl/ActorRefSinkActor.scala
  2030. @@ -26,11 +26,11 @@ import akka.annotation.InternalApi
  2031. @InternalApi private[akka] class ActorRefSinkActor(ref: ActorRef, highWatermark: Int, onCompleteMessage: Any) extends ActorSubscriber {
  2032. import ActorSubscriberMessage._
  2033.  
  2034. - override val requestStrategy = WatermarkRequestStrategy(highWatermark)
  2035. + override val requestStrategy: WatermarkRequestStrategy = WatermarkRequestStrategy(highWatermark)
  2036.  
  2037. context.watch(ref)
  2038.  
  2039. - def receive = {
  2040. + def receive: PartialFunction[Any, Unit] = {
  2041. case OnNext(elem) ⇒
  2042. ref.tell(elem, ActorRef.noSender)
  2043. case OnError(cause) ⇒
  2044. diff --git a/akka-stream/src/main/scala/akka/stream/impl/ActorRefSourceActor.scala b/akka-stream/src/main/scala/akka/stream/impl/ActorRefSourceActor.scala
  2045. index 356ba3647c..2738a128d4 100644
  2046. --- a/akka-stream/src/main/scala/akka/stream/impl/ActorRefSourceActor.scala
  2047. +++ b/akka-stream/src/main/scala/akka/stream/impl/ActorRefSourceActor.scala
  2048. @@ -15,7 +15,7 @@ import akka.stream.ActorMaterializerSettings
  2049. * INTERNAL API
  2050. */
  2051. @InternalApi private[akka] object ActorRefSourceActor {
  2052. - def props(bufferSize: Int, overflowStrategy: OverflowStrategy, settings: ActorMaterializerSettings) = {
  2053. + def props(bufferSize: Int, overflowStrategy: OverflowStrategy, settings: ActorMaterializerSettings): Props = {
  2054. require(overflowStrategy != OverflowStrategies.Backpressure, "Backpressure overflowStrategy not supported")
  2055. val maxFixedBufferSize = settings.maxFixedBufferSize
  2056. Props(new ActorRefSourceActor(bufferSize, overflowStrategy, maxFixedBufferSize))
  2057. @@ -30,9 +30,9 @@ import akka.stream.ActorMaterializerSettings
  2058. import akka.stream.actor.ActorPublisherMessage._
  2059.  
  2060. // when bufferSize is 0 there the buffer is not used
  2061. - protected val buffer = if (bufferSize == 0) null else Buffer[Any](bufferSize, maxFixedBufferSize)
  2062. + protected val buffer: Buffer[Any] = if (bufferSize == 0) null else Buffer[Any](bufferSize, maxFixedBufferSize)
  2063.  
  2064. - def receive = ({
  2065. + def receive: PartialFunction[Any, Unit] = ({
  2066. case Cancel ⇒
  2067. context.stop(self)
  2068.  
  2069. diff --git a/akka-stream/src/main/scala/akka/stream/impl/Buffers.scala b/akka-stream/src/main/scala/akka/stream/impl/Buffers.scala
  2070. index f63eef96ff..b3844a1e53 100644
  2071. --- a/akka-stream/src/main/scala/akka/stream/impl/Buffers.scala
  2072. +++ b/akka-stream/src/main/scala/akka/stream/impl/Buffers.scala
  2073. @@ -65,7 +65,7 @@ private[akka] object Buffer {
  2074. else new ModuloFixedSizeBuffer(size)
  2075.  
  2076. sealed abstract class FixedSizeBuffer[T](val capacity: Int) extends Buffer[T] {
  2077. - override def toString = s"Buffer($capacity, $readIdx, $writeIdx)(${(readIdx until writeIdx).map(get).mkString(", ")})"
  2078. + override def toString: String = s"Buffer($capacity, $readIdx, $writeIdx)(${(readIdx until writeIdx).map(get).mkString(", ")})"
  2079. private val buffer = new Array[AnyRef](capacity)
  2080.  
  2081. protected var readIdx = 0L
  2082. @@ -164,11 +164,11 @@ private[akka] object Buffer {
  2083. private var head = 0
  2084. private var tail = 0
  2085.  
  2086. - override def capacity = BoundedBuffer.this.capacity
  2087. - override def used = tail - head
  2088. - override def isFull = used == capacity
  2089. - override def isEmpty = tail == head
  2090. - override def nonEmpty = tail != head
  2091. + override def capacity: Int = BoundedBuffer.this.capacity
  2092. + override def used: Int = tail - head
  2093. + override def isFull: Boolean = used == capacity
  2094. + override def isEmpty: Boolean = tail == head
  2095. + override def nonEmpty: Boolean = tail != head
  2096.  
  2097. override def enqueue(elem: T): Unit =
  2098. if (tail - head == FixedQueueSize) {
  2099. @@ -205,10 +205,10 @@ private[akka] object Buffer {
  2100. }
  2101.  
  2102. private final class DynamicQueue(startIdx: Int) extends ju.LinkedList[T] with Buffer[T] {
  2103. - override def capacity = BoundedBuffer.this.capacity
  2104. - override def used = size
  2105. - override def isFull = size == capacity
  2106. - override def nonEmpty = !isEmpty()
  2107. + override def capacity: Int = BoundedBuffer.this.capacity
  2108. + override def used: Int = size
  2109. + override def isFull: Boolean = size == capacity
  2110. + override def nonEmpty: Boolean = !isEmpty()
  2111.  
  2112. override def enqueue(elem: T): Unit = add(elem)
  2113. override def dequeue(): T = remove()
  2114. diff --git a/akka-stream/src/main/scala/akka/stream/impl/ConstantFun.scala b/akka-stream/src/main/scala/akka/stream/impl/ConstantFun.scala
  2115. index 08c1964743..d93861c39b 100644
  2116. --- a/akka-stream/src/main/scala/akka/stream/impl/ConstantFun.scala
  2117. +++ b/akka-stream/src/main/scala/akka/stream/impl/ConstantFun.scala
  2118. @@ -6,6 +6,8 @@ package akka.stream.impl
  2119. import akka.annotation.InternalApi
  2120. import akka.japi.function.{ Function ⇒ JFun, Function2 ⇒ JFun2 }
  2121. import akka.japi.{ Pair ⇒ JPair }
  2122. +import akka.japi
  2123. +import akka.japi.function
  2124.  
  2125. /**
  2126. * INTERNAL API
  2127. @@ -16,7 +18,7 @@ import akka.japi.{ Pair ⇒ JPair }
  2128. @throws(classOf[Exception]) override def apply(param: Any): Any = param
  2129. }
  2130.  
  2131. - val JavaPairFunction = new JFun2[AnyRef, AnyRef, AnyRef JPair AnyRef] {
  2132. + val JavaPairFunction: function.Function2[AnyRef, AnyRef, japi.Pair[AnyRef, AnyRef]] = new JFun2[AnyRef, AnyRef, AnyRef JPair AnyRef] {
  2133. def apply(p1: AnyRef, p2: AnyRef): AnyRef JPair AnyRef = JPair(p1, p2)
  2134. }
  2135.  
  2136. @@ -30,16 +32,16 @@ import akka.japi.{ Pair ⇒ JPair }
  2137. def scalaAnyTwoToNone[A, B, C]: (A, B) ⇒ Option[C] = two2none
  2138. def javaAnyToNone[A, B]: A ⇒ Option[B] = none
  2139.  
  2140. - val conforms = (a: Any) ⇒ a
  2141. + val conforms: Any ⇒ Any = (a: Any) ⇒ a
  2142.  
  2143. - val zeroLong = (_: Any) ⇒ 0L
  2144. + val zeroLong: Any ⇒ Long = (_: Any) ⇒ 0L
  2145.  
  2146. - val oneLong = (_: Any) ⇒ 1L
  2147. + val oneLong: Any ⇒ Long = (_: Any) ⇒ 1L
  2148.  
  2149. - val oneInt = (_: Any) ⇒ 1
  2150. + val oneInt: Any ⇒ Int = (_: Any) ⇒ 1
  2151.  
  2152. - val none = (_: Any) ⇒ None
  2153. + val none: Any ⇒ None.type = (_: Any) ⇒ None
  2154.  
  2155. - val two2none = (_: Any, _: Any) ⇒ None
  2156. + val two2none: (Any, Any) ⇒ None.type = (_: Any, _: Any) ⇒ None
  2157.  
  2158. }
  2159. diff --git a/akka-stream/src/main/scala/akka/stream/impl/EmptySource.scala b/akka-stream/src/main/scala/akka/stream/impl/EmptySource.scala
  2160. index 790dea0b84..14ca712613 100644
  2161. --- a/akka-stream/src/main/scala/akka/stream/impl/EmptySource.scala
  2162. +++ b/akka-stream/src/main/scala/akka/stream/impl/EmptySource.scala
  2163. @@ -12,10 +12,10 @@ import akka.stream.stage._
  2164. * INTERNAL API
  2165. */
  2166. @InternalApi private[akka] final object EmptySource extends GraphStage[SourceShape[Nothing]] {
  2167. - val out = Outlet[Nothing]("EmptySource.out")
  2168. - override val shape = SourceShape(out)
  2169. + val out: Outlet[Nothing] = Outlet[Nothing]("EmptySource.out")
  2170. + override val shape: SourceShape[Nothing] = SourceShape(out)
  2171.  
  2172. - override protected def initialAttributes = DefaultAttributes.lazySource
  2173. + override protected def initialAttributes: Attributes = DefaultAttributes.lazySource
  2174.  
  2175. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  2176. new GraphStageLogic(shape) with OutHandler {
  2177. diff --git a/akka-stream/src/main/scala/akka/stream/impl/FailedSource.scala b/akka-stream/src/main/scala/akka/stream/impl/FailedSource.scala
  2178. index 24c50f16e9..743ea81078 100644
  2179. --- a/akka-stream/src/main/scala/akka/stream/impl/FailedSource.scala
  2180. +++ b/akka-stream/src/main/scala/akka/stream/impl/FailedSource.scala
  2181. @@ -12,8 +12,8 @@ import akka.stream.stage.{ GraphStage, GraphStageLogic, OutHandler }
  2182. * INTERNAL API
  2183. */
  2184. @InternalApi private[akka] final class FailedSource[T](failure: Throwable) extends GraphStage[SourceShape[T]] {
  2185. - val out = Outlet[T]("FailedSource.out")
  2186. - override val shape = SourceShape(out)
  2187. + val out: Outlet[T] = Outlet[T]("FailedSource.out")
  2188. + override val shape: SourceShape[T] = SourceShape(out)
  2189.  
  2190. override protected def initialAttributes: Attributes = DefaultAttributes.failedSource
  2191.  
  2192. @@ -27,5 +27,5 @@ import akka.stream.stage.{ GraphStage, GraphStageLogic, OutHandler }
  2193. setHandler(out, this)
  2194. }
  2195.  
  2196. - override def toString = s"FailedSource(${failure.getClass.getName})"
  2197. + override def toString: String = s"FailedSource(${failure.getClass.getName})"
  2198. }
  2199. diff --git a/akka-stream/src/main/scala/akka/stream/impl/FanIn.scala b/akka-stream/src/main/scala/akka/stream/impl/FanIn.scala
  2200. index 7ed42fa9cf..c796d0dc5e 100644
  2201. --- a/akka-stream/src/main/scala/akka/stream/impl/FanIn.scala
  2202. +++ b/akka-stream/src/main/scala/akka/stream/impl/FanIn.scala
  2203. @@ -94,7 +94,7 @@ import org.reactivestreams.{ Subscriber, Subscription }
  2204.  
  2205. private var preferredId = 0
  2206. private var _lastDequeuedId = 0
  2207. - def lastDequeuedId = _lastDequeuedId
  2208. + def lastDequeuedId: Int = _lastDequeuedId
  2209.  
  2210. def cancel(): Unit =
  2211. if (!allCancelled) {
  2212. @@ -106,7 +106,7 @@ import org.reactivestreams.{ Subscriber, Subscription }
  2213. }
  2214. }
  2215.  
  2216. - def cancel(input: Int) =
  2217. + def cancel(input: Int): Unit =
  2218. if (!cancelled(input)) {
  2219. inputs(input).cancel()
  2220. cancelled(input, on = true)
  2221. @@ -204,22 +204,22 @@ import org.reactivestreams.{ Subscriber, Subscription }
  2222. dequeue(id)
  2223. }
  2224.  
  2225. - val AllOfMarkedInputs = new TransferState {
  2226. + val AllOfMarkedInputs: TransferState = new TransferState {
  2227. override def isCompleted: Boolean = markedDepleted > 0
  2228. override def isReady: Boolean = markedPending == markCount
  2229. }
  2230.  
  2231. - val AnyOfMarkedInputs = new TransferState {
  2232. + val AnyOfMarkedInputs: TransferState = new TransferState {
  2233. override def isCompleted: Boolean = markedDepleted == markCount && markedPending == 0
  2234. override def isReady: Boolean = markedPending > 0
  2235. }
  2236.  
  2237. - def inputsAvailableFor(id: Int) = new TransferState {
  2238. + def inputsAvailableFor(id: Int): TransferState = new TransferState {
  2239. override def isCompleted: Boolean = depleted(id) || cancelled(id) || (!pending(id) && completed(id))
  2240. override def isReady: Boolean = pending(id)
  2241. }
  2242.  
  2243. - def inputsOrCompleteAvailableFor(id: Int) = new TransferState {
  2244. + def inputsOrCompleteAvailableFor(id: Int): TransferState = new TransferState {
  2245. override def isCompleted: Boolean = false
  2246. override def isReady: Boolean = pending(id) || depleted(id)
  2247. }
  2248. @@ -257,7 +257,7 @@ import org.reactivestreams.{ Subscriber, Subscription }
  2249. import FanIn._
  2250.  
  2251. protected val primaryOutputs: Outputs = new SimpleOutputs(self, this)
  2252. - protected val inputBunch = new InputBunch(inputCount, settings.maxInputBufferSize, this) {
  2253. + protected val inputBunch: InputBunch = new InputBunch(inputCount, settings.maxInputBufferSize, this) {
  2254. override def onError(input: Int, e: Throwable): Unit = fail(e)
  2255. override def onCompleteWhenNoInput(): Unit = pumpFinished()
  2256. }
  2257. @@ -288,7 +288,7 @@ import org.reactivestreams.{ Subscriber, Subscription }
  2258. throw new IllegalStateException("This actor cannot be restarted")
  2259. }
  2260.  
  2261. - def receive = inputBunch.subreceive.orElse[Any, Unit](primaryOutputs.subreceive)
  2262. + def receive: PartialFunction[Any, Unit] = inputBunch.subreceive.orElse[Any, Unit](primaryOutputs.subreceive)
  2263.  
  2264. }
  2265.  
  2266. diff --git a/akka-stream/src/main/scala/akka/stream/impl/FanOut.scala b/akka-stream/src/main/scala/akka/stream/impl/FanOut.scala
  2267. index f5b413f101..5ea32a45aa 100644
  2268. --- a/akka-stream/src/main/scala/akka/stream/impl/FanOut.scala
  2269. +++ b/akka-stream/src/main/scala/akka/stream/impl/FanOut.scala
  2270. @@ -22,7 +22,7 @@ import org.reactivestreams.Subscription
  2271. class SubstreamSubscription(val parent: ActorRef, val id: Int) extends Subscription {
  2272. override def request(elements: Long): Unit = parent ! SubstreamRequestMore(id, elements)
  2273. override def cancel(): Unit = parent ! SubstreamCancel(id)
  2274. - override def toString = "SubstreamSubscription" + System.identityHashCode(this)
  2275. + override def toString: String = "SubstreamSubscription" + System.identityHashCode(this)
  2276. }
  2277.  
  2278. class FanoutOutputs(val id: Int, _impl: ActorRef, _pump: Pump) extends SimpleOutputs(_impl, _pump) {
  2279. @@ -76,7 +76,7 @@ import org.reactivestreams.Subscription
  2280. }
  2281. }
  2282.  
  2283. - def complete(output: Int) =
  2284. + def complete(output: Int): Unit =
  2285. if (!completed(output) && !errored(output) && !cancelled(output)) {
  2286. outputs(output).complete()
  2287. completed(output) = true
  2288. @@ -183,12 +183,12 @@ import org.reactivestreams.Subscription
  2289.  
  2290. def onCancel(output: Int): Unit = ()
  2291.  
  2292. - def demandAvailableFor(id: Int) = new TransferState {
  2293. + def demandAvailableFor(id: Int): TransferState = new TransferState {
  2294. override def isCompleted: Boolean = cancelled(id) || completed(id) || errored(id)
  2295. override def isReady: Boolean = pending(id)
  2296. }
  2297.  
  2298. - def demandOrCancelAvailableFor(id: Int) = new TransferState {
  2299. + def demandOrCancelAvailableFor(id: Int): TransferState = new TransferState {
  2300. override def isCompleted: Boolean = false
  2301. override def isReady: Boolean = pending(id) || cancelled(id)
  2302. }
  2303. @@ -198,7 +198,7 @@ import org.reactivestreams.Subscription
  2304. * have demand, and will complete as soon as any of the marked
  2305. * outputs have canceled.
  2306. */
  2307. - val AllOfMarkedOutputs = new TransferState {
  2308. + val AllOfMarkedOutputs: TransferState = new TransferState {
  2309. override def isCompleted: Boolean = markedCancelled > 0 || markedCount == 0
  2310. override def isReady: Boolean = markedPending == markedCount
  2311. }
  2312. @@ -208,7 +208,7 @@ import org.reactivestreams.Subscription
  2313. * have demand, and will complete when all of the marked
  2314. * outputs have canceled.
  2315. */
  2316. - val AnyOfMarkedOutputs = new TransferState {
  2317. + val AnyOfMarkedOutputs: TransferState = new TransferState {
  2318. override def isCompleted: Boolean = markedCancelled == markedCount
  2319. override def isReady: Boolean = markedPending > 0
  2320. }
  2321. @@ -251,7 +251,7 @@ import org.reactivestreams.Subscription
  2322. @DoNotInherit private[akka] abstract class FanOut(val settings: ActorMaterializerSettings, val outputCount: Int) extends Actor with ActorLogging with Pump {
  2323. import FanOut._
  2324.  
  2325. - protected val outputBunch = new OutputBunch(outputCount, self, this)
  2326. + protected val outputBunch: OutputBunch = new OutputBunch(outputCount, self, this)
  2327. protected val primaryInputs: Inputs = new BatchingInputBuffer(settings.maxInputBufferSize, this) {
  2328. override def onError(e: Throwable): Unit = fail(e)
  2329. }
  2330. @@ -282,7 +282,7 @@ import org.reactivestreams.Subscription
  2331. throw new IllegalStateException("This actor cannot be restarted")
  2332. }
  2333.  
  2334. - def receive = primaryInputs.subreceive.orElse[Any, Unit](outputBunch.subreceive)
  2335. + def receive: PartialFunction[Any, Unit] = primaryInputs.subreceive.orElse[Any, Unit](outputBunch.subreceive)
  2336. }
  2337.  
  2338. /**
  2339. diff --git a/akka-stream/src/main/scala/akka/stream/impl/FanoutProcessor.scala b/akka-stream/src/main/scala/akka/stream/impl/FanoutProcessor.scala
  2340. index 27f1296a74..870b2ba513 100644
  2341. --- a/akka-stream/src/main/scala/akka/stream/impl/FanoutProcessor.scala
  2342. +++ b/akka-stream/src/main/scala/akka/stream/impl/FanoutProcessor.scala
  2343. @@ -1,136 +1,136 @@
  2344. package akka.stream.impl
  2345. -
  2346. -import akka.actor.{ Actor, ActorRef, Deploy, Props }
  2347. -import akka.annotation.{ DoNotInherit, InternalApi }
  2348. -import akka.stream.{ ActorMaterializerSettings, Attributes }
  2349. +
  2350. +import akka.actor.{ Actor, ActorRef, Deploy, Props }
  2351. +import akka.annotation.{ DoNotInherit, InternalApi }
  2352. +import akka.stream.{ ActorMaterializerSettings, Attributes }
  2353. import org.reactivestreams.Subscriber
  2354. -
  2355. +
  2356. /**
  2357. * INTERNAL API
  2358. */
  2359. -@DoNotInherit private[akka] abstract class FanoutOutputs(
  2360. - val maxBufferSize: Int,
  2361. - val initialBufferSize: Int,
  2362. - self: ActorRef,
  2363. - val pump: Pump)
  2364. +@DoNotInherit private[akka] abstract class FanoutOutputs(
  2365. + val maxBufferSize: Int,
  2366. + val initialBufferSize: Int,
  2367. + self: ActorRef,
  2368. + val pump: Pump)
  2369. extends DefaultOutputTransferStates
  2370. - with SubscriberManagement[Any] {
  2371. -
  2372. - override type S = ActorSubscriptionWithCursor[_ >: Any]
  2373. - override def createSubscription(subscriber: Subscriber[_ >: Any]): S =
  2374. - new ActorSubscriptionWithCursor(self, subscriber)
  2375. -
  2376. - protected var exposedPublisher: ActorPublisher[Any] = _
  2377. -
  2378. + with SubscriberManagement[Any] {
  2379. +
  2380. + override type S = ActorSubscriptionWithCursor[_ >: Any]
  2381. + override def createSubscription(subscriber: Subscriber[_ >: Any]): S =
  2382. + new ActorSubscriptionWithCursor(self, subscriber)
  2383. +
  2384. + protected var exposedPublisher: ActorPublisher[Any] = _
  2385. +
  2386. private var downstreamBufferSpace: Long = 0L
  2387. - private var downstreamCompleted = false
  2388. - override def demandAvailable = downstreamBufferSpace > 0
  2389. + private var downstreamCompleted = false
  2390. + override def demandAvailable: Boolean = downstreamBufferSpace > 0
  2391. override def demandCount: Long = downstreamBufferSpace
  2392. -
  2393. - override val subreceive = new SubReceive(waitingExposedPublisher)
  2394. -
  2395. - def enqueueOutputElement(elem: Any): Unit = {
  2396. - ReactiveStreamsCompliance.requireNonNullElement(elem)
  2397. +
  2398. + override val subreceive: SubReceive = new SubReceive(waitingExposedPublisher)
  2399. +
  2400. + def enqueueOutputElement(elem: Any): Unit = {
  2401. + ReactiveStreamsCompliance.requireNonNullElement(elem)
  2402. downstreamBufferSpace -= 1
  2403. - pushToDownstream(elem)
  2404. - }
  2405. -
  2406. - override def complete(): Unit =
  2407. - if (!downstreamCompleted) {
  2408. - downstreamCompleted = true
  2409. - completeDownstream()
  2410. - }
  2411. -
  2412. - override def cancel(): Unit = complete()
  2413. -
  2414. - override def error(e: Throwable): Unit = {
  2415. - if (!downstreamCompleted) {
  2416. - downstreamCompleted = true
  2417. - abortDownstream(e)
  2418. - if (exposedPublisher ne null) exposedPublisher.shutdown(Some(e))
  2419. - }
  2420. - }
  2421. -
  2422. + pushToDownstream(elem)
  2423. + }
  2424. +
  2425. + override def complete(): Unit =
  2426. + if (!downstreamCompleted) {
  2427. + downstreamCompleted = true
  2428. + completeDownstream()
  2429. + }
  2430. +
  2431. + override def cancel(): Unit = complete()
  2432. +
  2433. + override def error(e: Throwable): Unit = {
  2434. + if (!downstreamCompleted) {
  2435. + downstreamCompleted = true
  2436. + abortDownstream(e)
  2437. + if (exposedPublisher ne null) exposedPublisher.shutdown(Some(e))
  2438. + }
  2439. + }
  2440. +
  2441. def isClosed: Boolean = downstreamCompleted
  2442. -
  2443. +
  2444. def afterShutdown(): Unit
  2445. -
  2446. +
  2447. override protected def requestFromUpstream(elements: Long): Unit = downstreamBufferSpace += elements
  2448. -
  2449. - private def subscribePending(): Unit =
  2450. +
  2451. + private def subscribePending(): Unit =
  2452. exposedPublisher.takePendingSubscribers() foreach registerSubscriber
  2453. -
  2454. - override protected def shutdown(completed: Boolean): Unit = {
  2455. - if (exposedPublisher ne null) {
  2456. - if (completed) exposedPublisher.shutdown(None)
  2457. - else exposedPublisher.shutdown(ActorPublisher.SomeNormalShutdownReason)
  2458. - }
  2459. - afterShutdown()
  2460. - }
  2461. -
  2462. - override protected def cancelUpstream(): Unit = {
  2463. - downstreamCompleted = true
  2464. - }
  2465. -
  2466. - protected def waitingExposedPublisher: Actor.Receive = {
  2467. +
  2468. + override protected def shutdown(completed: Boolean): Unit = {
  2469. + if (exposedPublisher ne null) {
  2470. + if (completed) exposedPublisher.shutdown(None)
  2471. + else exposedPublisher.shutdown(ActorPublisher.SomeNormalShutdownReason)
  2472. + }
  2473. + afterShutdown()
  2474. + }
  2475. +
  2476. + override protected def cancelUpstream(): Unit = {
  2477. + downstreamCompleted = true
  2478. + }
  2479. +
  2480. + protected def waitingExposedPublisher: Actor.Receive = {
  2481. case ExposedPublisher(publisher) ⇒
  2482. exposedPublisher = publisher
  2483. - subreceive.become(downstreamRunning)
  2484. + subreceive.become(downstreamRunning)
  2485. case other ⇒
  2486. - throw new IllegalStateException(s"The first message must be ExposedPublisher but was [$other]")
  2487. - }
  2488. -
  2489. - protected def downstreamRunning: Actor.Receive = {
  2490. + throw new IllegalStateException(s"The first message must be ExposedPublisher but was [$other]")
  2491. + }
  2492. +
  2493. + protected def downstreamRunning: Actor.Receive = {
  2494. case SubscribePending ⇒
  2495. - subscribePending()
  2496. + subscribePending()
  2497. case RequestMore(subscription, elements) ⇒
  2498. - moreRequested(subscription.asInstanceOf[ActorSubscriptionWithCursor[Any]], elements)
  2499. - pump.pump()
  2500. + moreRequested(subscription.asInstanceOf[ActorSubscriptionWithCursor[Any]], elements)
  2501. + pump.pump()
  2502. case Cancel(subscription) ⇒
  2503. - unregisterSubscription(subscription.asInstanceOf[ActorSubscriptionWithCursor[Any]])
  2504. - pump.pump()
  2505. - }
  2506. -
  2507. -}
  2508. -
  2509. + unregisterSubscription(subscription.asInstanceOf[ActorSubscriptionWithCursor[Any]])
  2510. + pump.pump()
  2511. + }
  2512. +
  2513. +}
  2514. +
  2515. /**
  2516. * INTERNAL API
  2517. */
  2518. -@InternalApi private[akka] object FanoutProcessorImpl {
  2519. - def props(attributes: Attributes, actorMaterializerSettings: ActorMaterializerSettings): Props =
  2520. - Props(new FanoutProcessorImpl(attributes, actorMaterializerSettings)).withDeploy(Deploy.local)
  2521. -}
  2522. +@InternalApi private[akka] object FanoutProcessorImpl {
  2523. + def props(attributes: Attributes, actorMaterializerSettings: ActorMaterializerSettings): Props =
  2524. + Props(new FanoutProcessorImpl(attributes, actorMaterializerSettings)).withDeploy(Deploy.local)
  2525. +}
  2526. /**
  2527. * INTERNAL API
  2528. */
  2529. -@InternalApi private[akka] class FanoutProcessorImpl(attributes: Attributes, _settings: ActorMaterializerSettings)
  2530. - extends ActorProcessorImpl(attributes, _settings) {
  2531. -
  2532. - override val primaryOutputs: FanoutOutputs = {
  2533. - val inputBuffer = attributes.mandatoryAttribute[Attributes.InputBuffer]
  2534. - new FanoutOutputs(inputBuffer.max, inputBuffer.initial, self, this) {
  2535. - override def afterShutdown(): Unit = afterFlush()
  2536. - }
  2537. - }
  2538. -
  2539. +@InternalApi private[akka] class FanoutProcessorImpl(attributes: Attributes, _settings: ActorMaterializerSettings)
  2540. + extends ActorProcessorImpl(attributes, _settings) {
  2541. +
  2542. + override val primaryOutputs: FanoutOutputs = {
  2543. + val inputBuffer = attributes.mandatoryAttribute[Attributes.InputBuffer]
  2544. + new FanoutOutputs(inputBuffer.max, inputBuffer.initial, self, this) {
  2545. + override def afterShutdown(): Unit = afterFlush()
  2546. + }
  2547. + }
  2548. +
  2549. val running: TransferPhase = TransferPhase(primaryInputs.NeedsInput && primaryOutputs.NeedsDemand) { () ⇒
  2550. - primaryOutputs.enqueueOutputElement(primaryInputs.dequeueInputElement())
  2551. - }
  2552. -
  2553. - override def fail(e: Throwable): Unit = {
  2554. - if (settings.debugLogging)
  2555. - log.debug("fail due to: {}", e.getMessage)
  2556. - primaryInputs.cancel()
  2557. - primaryOutputs.error(e)
  2558. + primaryOutputs.enqueueOutputElement(primaryInputs.dequeueInputElement())
  2559. + }
  2560. +
  2561. + override def fail(e: Throwable): Unit = {
  2562. + if (settings.debugLogging)
  2563. + log.debug("fail due to: {}", e.getMessage)
  2564. + primaryInputs.cancel()
  2565. + primaryOutputs.error(e)
  2566. // Stopping will happen after flush
  2567. - }
  2568. -
  2569. - override def pumpFinished(): Unit = {
  2570. - primaryInputs.cancel()
  2571. - primaryOutputs.complete()
  2572. - }
  2573. -
  2574. - def afterFlush(): Unit = context.stop(self)
  2575. -
  2576. - initialPhase(1, running)
  2577. -}
  2578. + }
  2579. +
  2580. + override def pumpFinished(): Unit = {
  2581. + primaryInputs.cancel()
  2582. + primaryOutputs.complete()
  2583. + }
  2584. +
  2585. + def afterFlush(): Unit = context.stop(self)
  2586. +
  2587. + initialPhase(1, running)
  2588. +}
  2589. diff --git a/akka-stream/src/main/scala/akka/stream/impl/JsonObjectParser.scala b/akka-stream/src/main/scala/akka/stream/impl/JsonObjectParser.scala
  2590. index f9d6727126..5c28aeeef2 100644
  2591. --- a/akka-stream/src/main/scala/akka/stream/impl/JsonObjectParser.scala
  2592. +++ b/akka-stream/src/main/scala/akka/stream/impl/JsonObjectParser.scala
  2593. @@ -14,20 +14,20 @@ import scala.annotation.switch
  2594. */
  2595. @InternalApi private[akka] object JsonObjectParser {
  2596.  
  2597. - final val SquareBraceStart = '['.toByte
  2598. - final val SquareBraceEnd = ']'.toByte
  2599. - final val CurlyBraceStart = '{'.toByte
  2600. - final val CurlyBraceEnd = '}'.toByte
  2601. - final val DoubleQuote = '"'.toByte
  2602. - final val Backslash = '\\'.toByte
  2603. - final val Comma = ','.toByte
  2604. -
  2605. - final val LineBreak = '\n'.toByte
  2606. - final val LineBreak2 = '\r'.toByte
  2607. - final val Tab = '\t'.toByte
  2608. - final val Space = ' '.toByte
  2609. -
  2610. - final val Whitespace = Set(LineBreak, LineBreak2, Tab, Space)
  2611. + final val SquareBraceStart: Byte = '['.toByte
  2612. + final val SquareBraceEnd: Byte = ']'.toByte
  2613. + final val CurlyBraceStart: Byte = '{'.toByte
  2614. + final val CurlyBraceEnd: Byte = '}'.toByte
  2615. + final val DoubleQuote: Byte = '"'.toByte
  2616. + final val Backslash: Byte = '\\'.toByte
  2617. + final val Comma: Byte = ','.toByte
  2618. +
  2619. + final val LineBreak: Byte = '\n'.toByte
  2620. + final val LineBreak2: Byte = '\r'.toByte
  2621. + final val Tab: Byte = '\t'.toByte
  2622. + final val Space: Byte = ' '.toByte
  2623. +
  2624. + final val Whitespace: Set[Byte] = Set(LineBreak, LineBreak2, Tab, Space)
  2625.  
  2626. def isWhitespace(input: Byte): Boolean =
  2627. Whitespace.contains(input)
  2628. diff --git a/akka-stream/src/main/scala/akka/stream/impl/LazySource.scala b/akka-stream/src/main/scala/akka/stream/impl/LazySource.scala
  2629. index 745e936d3c..d7b603a607 100644
  2630. --- a/akka-stream/src/main/scala/akka/stream/impl/LazySource.scala
  2631. +++ b/akka-stream/src/main/scala/akka/stream/impl/LazySource.scala
  2632. @@ -16,17 +16,17 @@ import scala.util.control.NonFatal
  2633. * INTERNAL API
  2634. */
  2635. @InternalApi private[akka] object LazySource {
  2636. - def apply[T, M](sourceFactory: () ⇒ Source[T, M]) = new LazySource[T, M](sourceFactory)
  2637. + def apply[T, M](sourceFactory: () ⇒ Source[T, M]): LazySource[T, M] = new LazySource[T, M](sourceFactory)
  2638. }
  2639.  
  2640. /**
  2641. * INTERNAL API
  2642. */
  2643. @InternalApi private[akka] final class LazySource[T, M](sourceFactory: () ⇒ Source[T, M]) extends GraphStageWithMaterializedValue[SourceShape[T], Future[M]] {
  2644. - val out = Outlet[T]("LazySource.out")
  2645. - override val shape = SourceShape(out)
  2646. + val out: Outlet[T] = Outlet[T]("LazySource.out")
  2647. + override val shape: SourceShape[T] = SourceShape(out)
  2648.  
  2649. - override protected def initialAttributes = DefaultAttributes.lazySource
  2650. + override protected def initialAttributes: Attributes = DefaultAttributes.lazySource
  2651.  
  2652. override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, Future[M]) = {
  2653. val matPromise = Promise[M]()
  2654. @@ -72,7 +72,7 @@ import scala.util.control.NonFatal
  2655.  
  2656. setHandler(out, this)
  2657.  
  2658. - override def postStop() = {
  2659. + override def postStop(): Unit = {
  2660. matPromise.tryFailure(new RuntimeException("LazySource stopped without completing the materialized future"))
  2661. }
  2662. }
  2663. diff --git a/akka-stream/src/main/scala/akka/stream/impl/MaybeSource.scala b/akka-stream/src/main/scala/akka/stream/impl/MaybeSource.scala
  2664. index 6f075a8bab..8f85177bb5 100644
  2665. --- a/akka-stream/src/main/scala/akka/stream/impl/MaybeSource.scala
  2666. +++ b/akka-stream/src/main/scala/akka/stream/impl/MaybeSource.scala
  2667. @@ -17,10 +17,10 @@ import scala.util.Try
  2668. * INTERNAL API
  2669. */
  2670. @InternalApi private[akka] object MaybeSource extends GraphStageWithMaterializedValue[SourceShape[AnyRef], Promise[Option[AnyRef]]] {
  2671. - val out = Outlet[AnyRef]("MaybeSource.out")
  2672. - override val shape = SourceShape(out)
  2673. + val out: Outlet[AnyRef] = Outlet[AnyRef]("MaybeSource.out")
  2674. + override val shape: SourceShape[AnyRef] = SourceShape(out)
  2675.  
  2676. - override protected def initialAttributes = DefaultAttributes.maybeSource
  2677. + override protected def initialAttributes: Attributes = DefaultAttributes.maybeSource
  2678.  
  2679. override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, Promise[Option[AnyRef]]) = {
  2680. import scala.util.{ Success ⇒ ScalaSuccess, Failure ⇒ ScalaFailure }
  2681. diff --git a/akka-stream/src/main/scala/akka/stream/impl/Modules.scala b/akka-stream/src/main/scala/akka/stream/impl/Modules.scala
  2682. index a590ea0a61..187eed69ef 100644
  2683. --- a/akka-stream/src/main/scala/akka/stream/impl/Modules.scala
  2684. +++ b/akka-stream/src/main/scala/akka/stream/impl/Modules.scala
  2685. @@ -72,7 +72,7 @@ import akka.util.OptionVal
  2686.  
  2687. override protected def label: String = s"PublisherSource($p)"
  2688.  
  2689. - override def create(context: MaterializationContext) = (p, NotUsed)
  2690. + override def create(context: MaterializationContext): (Publisher[Out], NotUsed.type) = (p, NotUsed)
  2691.  
  2692. override protected def newInstance(shape: SourceShape[Out]): SourceModule[Out, NotUsed] = new PublisherSource[Out](p, attributes, shape)
  2693. override def withAttributes(attr: Attributes): SourceModule[Out, NotUsed] = new PublisherSource[Out](p, attr, amendShape(attr))
  2694. @@ -85,7 +85,7 @@ import akka.util.OptionVal
  2695. */
  2696. @InternalApi private[akka] final class ActorPublisherSource[Out](props: Props, val attributes: Attributes, shape: SourceShape[Out]) extends SourceModule[Out, ActorRef](shape) {
  2697.  
  2698. - override def create(context: MaterializationContext) = {
  2699. + override def create(context: MaterializationContext): (Publisher[Out], ActorRef) = {
  2700. val publisherRef = ActorMaterializerHelper.downcast(context.materializer).actorOf(context, props)
  2701. (akka.stream.actor.ActorPublisher[Out](publisherRef), publisherRef)
  2702. }
  2703. @@ -104,7 +104,7 @@ import akka.util.OptionVal
  2704.  
  2705. override protected def label: String = s"ActorRefSource($bufferSize, $overflowStrategy)"
  2706.  
  2707. - override def create(context: MaterializationContext) = {
  2708. + override def create(context: MaterializationContext): (Publisher[Out], ActorRef) = {
  2709. val mat = ActorMaterializerHelper.downcast(context.materializer)
  2710. val ref = mat.actorOf(context, ActorRefSourceActor.props(bufferSize, overflowStrategy, mat.settings))
  2711. (akka.stream.actor.ActorPublisher[Out](ref), ref)
  2712. diff --git a/akka-stream/src/main/scala/akka/stream/impl/PhasedFusingActorMaterializer.scala b/akka-stream/src/main/scala/akka/stream/impl/PhasedFusingActorMaterializer.scala
  2713. index 588cfb787a..3fcac88bfa 100644
  2714. --- a/akka-stream/src/main/scala/akka/stream/impl/PhasedFusingActorMaterializer.scala
  2715. +++ b/akka-stream/src/main/scala/akka/stream/impl/PhasedFusingActorMaterializer.scala
  2716. @@ -27,6 +27,7 @@ import scala.concurrent.duration.FiniteDuration
  2717. import scala.concurrent.ExecutionContextExecutor
  2718. import scala.annotation.tailrec
  2719. import akka.util.OptionVal
  2720. +import akka.stream.impl.FanOut.SubstreamSubscribePending
  2721.  
  2722. /**
  2723. * INTERNAL API
  2724. @@ -382,7 +383,7 @@ private final case class SavedIslandData(islandGlobalOffset: Int, lastVisitedOff
  2725. * When these attributes are needed later in the materialization process it is important that the
  2726. * they are gotten through the attributes and not through the [[ActorMaterializerSettings]]
  2727. */
  2728. - val defaultAttributes = {
  2729. + val defaultAttributes: Attributes = {
  2730. Attributes(
  2731. Attributes.InputBuffer(settings.initialInputBufferSize, settings.maxInputBufferSize) ::
  2732. ActorAttributes.SupervisionStrategy(settings.supervisionDecider) ::
  2733. @@ -615,7 +616,7 @@ private final case class SavedIslandData(islandGlobalOffset: Int, lastVisitedOff
  2734. private var outConnections: List[Connection] = Nil
  2735. private var fullIslandName: OptionVal[String] = OptionVal.None
  2736.  
  2737. - val shell = new GraphInterpreterShell(
  2738. + val shell: GraphInterpreterShell = new GraphInterpreterShell(
  2739. connections = null,
  2740. logics = null,
  2741. settings,
  2742. @@ -887,7 +888,7 @@ private final case class SavedIslandData(islandGlobalOffset: Int, lastVisitedOff
  2743. TLSActor.props(maxInputBuffer, tls.createSSLEngine, tls.verifySession, tls.closing).withDispatcher(dispatcher)
  2744. tlsActor = materializer.actorOf(props, islandName)
  2745. def factory(id: Int) = new ActorPublisher[Any](tlsActor) {
  2746. - override val wakeUpMsg = FanOut.SubstreamSubscribePending(id)
  2747. + override val wakeUpMsg: SubstreamSubscribePending = FanOut.SubstreamSubscribePending(id)
  2748. }
  2749. publishers = Vector.tabulate(2)(factory)
  2750. tlsActor ! FanOut.ExposedPublishers(publishers)
  2751. diff --git a/akka-stream/src/main/scala/akka/stream/impl/QueueSource.scala b/akka-stream/src/main/scala/akka/stream/impl/QueueSource.scala
  2752. index a53cd9a97c..b9c652d8c1 100644
  2753. --- a/akka-stream/src/main/scala/akka/stream/impl/QueueSource.scala
  2754. +++ b/akka-stream/src/main/scala/akka/stream/impl/QueueSource.scala
  2755. @@ -34,10 +34,10 @@ import scala.util.control.NonFatal
  2756. @InternalApi private[akka] final class QueueSource[T](maxBuffer: Int, overflowStrategy: OverflowStrategy) extends GraphStageWithMaterializedValue[SourceShape[T], SourceQueueWithComplete[T]] {
  2757. import QueueSource._
  2758.  
  2759. - val out = Outlet[T]("queueSource.out")
  2760. + val out: Outlet[T] = Outlet[T]("queueSource.out")
  2761. override val shape: SourceShape[T] = SourceShape.of(out)
  2762.  
  2763. - override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
  2764. + override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic with OutHandler with SourceQueueWithComplete[T], GraphStageLogic with OutHandler with SourceQueueWithComplete[T]) = {
  2765. val completion = Promise[Done]
  2766.  
  2767. val stageLogic = new GraphStageLogic(shape) with OutHandler with SourceQueueWithComplete[T] {
  2768. @@ -167,7 +167,7 @@ import scala.util.control.NonFatal
  2769. }
  2770.  
  2771. // SourceQueueWithComplete impl
  2772. - override def watchCompletion() = completion.future
  2773. + override def watchCompletion(): Future[Done] = completion.future
  2774. override def offer(element: T): Future[QueueOfferResult] = {
  2775. val p = Promise[QueueOfferResult]
  2776. callback.invokeWithFeedback(Offer(element, p))
  2777. diff --git a/akka-stream/src/main/scala/akka/stream/impl/SeqActorName.scala b/akka-stream/src/main/scala/akka/stream/impl/SeqActorName.scala
  2778. index eb8f061e66..49f97d3b4f 100644
  2779. --- a/akka-stream/src/main/scala/akka/stream/impl/SeqActorName.scala
  2780. +++ b/akka-stream/src/main/scala/akka/stream/impl/SeqActorName.scala
  2781. @@ -24,7 +24,7 @@ import akka.annotation.{ DoNotInherit, InternalApi }
  2782. * INTERNAL API
  2783. */
  2784. @InternalApi private[akka] object SeqActorName {
  2785. - def apply(prefix: String) = new SeqActorNameImpl(prefix, new AtomicLong(0))
  2786. + def apply(prefix: String): SeqActorNameImpl = new SeqActorNameImpl(prefix, new AtomicLong(0))
  2787. }
  2788.  
  2789. /**
  2790. diff --git a/akka-stream/src/main/scala/akka/stream/impl/Sinks.scala b/akka-stream/src/main/scala/akka/stream/impl/Sinks.scala
  2791. index b0a9cca2e9..0d11cfc84d 100644
  2792. --- a/akka-stream/src/main/scala/akka/stream/impl/Sinks.scala
  2793. +++ b/akka-stream/src/main/scala/akka/stream/impl/Sinks.scala
  2794. @@ -41,6 +41,7 @@ import akka.event.Logging
  2795. import akka.util.OptionVal
  2796.  
  2797. import scala.collection.generic.CanBuildFrom
  2798. +import scala.collection.mutable.Builder
  2799.  
  2800. /**
  2801. * INTERNAL API
  2802. @@ -133,7 +134,7 @@ import scala.collection.generic.CanBuildFrom
  2803. */
  2804. @InternalApi private[akka] final class SubscriberSink[In](subscriber: Subscriber[In], val attributes: Attributes, shape: SinkShape[In]) extends SinkModule[In, NotUsed](shape) {
  2805.  
  2806. - override def create(context: MaterializationContext) = (subscriber, NotUsed)
  2807. + override def create(context: MaterializationContext): (Subscriber[In], NotUsed.type) = (subscriber, NotUsed)
  2808.  
  2809. override protected def newInstance(shape: SinkShape[In]): SinkModule[In, NotUsed] = new SubscriberSink[In](subscriber, attributes, shape)
  2810. override def withAttributes(attr: Attributes): SinkModule[In, NotUsed] = new SubscriberSink[In](subscriber, attr, amendShape(attr))
  2811. @@ -156,7 +157,7 @@ import scala.collection.generic.CanBuildFrom
  2812. */
  2813. @InternalApi private[akka] final class ActorSubscriberSink[In](props: Props, val attributes: Attributes, shape: SinkShape[In]) extends SinkModule[In, ActorRef](shape) {
  2814.  
  2815. - override def create(context: MaterializationContext) = {
  2816. + override def create(context: MaterializationContext): (Subscriber[In], ActorRef) = {
  2817. val subscriberRef = ActorMaterializerHelper.downcast(context.materializer).actorOf(context, props)
  2818. (akka.stream.actor.ActorSubscriber[In](subscriberRef), subscriberRef)
  2819. }
  2820. @@ -172,7 +173,7 @@ import scala.collection.generic.CanBuildFrom
  2821. val attributes: Attributes,
  2822. shape: SinkShape[In]) extends SinkModule[In, NotUsed](shape) {
  2823.  
  2824. - override def create(context: MaterializationContext) = {
  2825. + override def create(context: MaterializationContext): (Subscriber[In], NotUsed.type) = {
  2826. val actorMaterializer = ActorMaterializerHelper.downcast(context.materializer)
  2827. val maxInputBufferSize = context.effectiveAttributes.mandatoryAttribute[Attributes.InputBuffer].max
  2828. val subscriberRef = actorMaterializer.actorOf(
  2829. @@ -196,7 +197,7 @@ import scala.collection.generic.CanBuildFrom
  2830.  
  2831. override val shape: SinkShape[T] = SinkShape.of(in)
  2832.  
  2833. - override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
  2834. + override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic with InHandler, Future[Option[T]]) = {
  2835. val p: Promise[Option[T]] = Promise()
  2836. (new GraphStageLogic(shape) with InHandler {
  2837. private[this] var prev: T = null.asInstanceOf[T]
  2838. @@ -237,7 +238,7 @@ import scala.collection.generic.CanBuildFrom
  2839.  
  2840. override val shape: SinkShape[T] = SinkShape.of(in)
  2841.  
  2842. - override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
  2843. + override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic with InHandler, Future[Option[T]]) = {
  2844. val p: Promise[Option[T]] = Promise()
  2845. (new GraphStageLogic(shape) with InHandler {
  2846. override def preStart(): Unit = pull(in)
  2847. @@ -272,7 +273,7 @@ import scala.collection.generic.CanBuildFrom
  2848. * INTERNAL API
  2849. */
  2850. @InternalApi private[akka] final class SeqStage[T, That](implicit cbf: CanBuildFrom[Nothing, T, That with immutable.Traversable[_]]) extends GraphStageWithMaterializedValue[SinkShape[T], Future[That]] {
  2851. - val in = Inlet[T]("seq.in")
  2852. + val in: Inlet[T] = Inlet[T]("seq.in")
  2853.  
  2854. override def toString: String = "SeqStage"
  2855.  
  2856. @@ -280,10 +281,10 @@ import scala.collection.generic.CanBuildFrom
  2857.  
  2858. override protected def initialAttributes: Attributes = DefaultAttributes.seqSink
  2859.  
  2860. - override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
  2861. + override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic with InHandler, Future[That]) = {
  2862. val p: Promise[That] = Promise()
  2863. val logic = new GraphStageLogic(shape) with InHandler {
  2864. - val buf = cbf()
  2865. + val buf: Builder[T, That with (immutable.Traversable[_$1] forSome { type _$1 })] = cbf()
  2866.  
  2867. override def preStart(): Unit = pull(in)
  2868.  
  2869. @@ -329,17 +330,17 @@ import scala.collection.generic.CanBuildFrom
  2870. @InternalApi private[akka] final class QueueSink[T]() extends GraphStageWithMaterializedValue[SinkShape[T], SinkQueueWithCancel[T]] {
  2871. type Requested[E] = Promise[Option[E]]
  2872.  
  2873. - val in = Inlet[T]("queueSink.in")
  2874. - override def initialAttributes = DefaultAttributes.queueSink
  2875. + val in: Inlet[T] = Inlet[T]("queueSink.in")
  2876. + override def initialAttributes: Attributes = DefaultAttributes.queueSink
  2877. override val shape: SinkShape[T] = SinkShape.of(in)
  2878.  
  2879. override def toString: String = "QueueSink"
  2880.  
  2881. - override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
  2882. + override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic with InHandler with SinkQueueWithCancel[T], GraphStageLogic with InHandler with SinkQueueWithCancel[T]) = {
  2883. val stageLogic = new GraphStageLogic(shape) with InHandler with SinkQueueWithCancel[T] {
  2884. type Received[E] = Try[Option[E]]
  2885.  
  2886. - val maxBuffer = inheritedAttributes.getAttribute(classOf[InputBuffer], InputBuffer(16, 16)).max
  2887. + val maxBuffer: Int = inheritedAttributes.getAttribute(classOf[InputBuffer], InputBuffer(16, 16)).max
  2888. require(maxBuffer > 0, "Buffer size must be greater than 0")
  2889.  
  2890. var buffer: Buffer[Received[T]] = _
  2891. @@ -429,7 +430,7 @@ import scala.collection.generic.CanBuildFrom
  2892. * Helper class to be able to express collection as a fold using mutable data
  2893. */
  2894. @InternalApi private[akka] final class CollectorState[T, R](val collector: java.util.stream.Collector[T, Any, R]) {
  2895. - lazy val accumulated = collector.supplier().get()
  2896. + lazy val accumulated: Any = collector.supplier().get()
  2897. private lazy val accumulator = collector.accumulator()
  2898.  
  2899. def update(elem: T): CollectorState[T, R] = {
  2900. @@ -462,13 +463,13 @@ import scala.collection.generic.CanBuildFrom
  2901. * INTERNAL API
  2902. */
  2903. @InternalApi final private[stream] class LazySink[T, M](sinkFactory: T ⇒ Future[Sink[T, M]], zeroMat: () ⇒ M) extends GraphStageWithMaterializedValue[SinkShape[T], Future[M]] {
  2904. - val in = Inlet[T]("lazySink.in")
  2905. - override def initialAttributes = DefaultAttributes.lazySink
  2906. + val in: Inlet[T] = Inlet[T]("lazySink.in")
  2907. + override def initialAttributes: Attributes = DefaultAttributes.lazySink
  2908. override val shape: SinkShape[T] = SinkShape.of(in)
  2909.  
  2910. override def toString: String = "LazySink"
  2911.  
  2912. - override def createLogicAndMaterializedValue(inheritedAttributes: Attributes) = {
  2913. + override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic with InHandler, Future[M]) = {
  2914. lazy val decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  2915.  
  2916. var completed = false
  2917. diff --git a/akka-stream/src/main/scala/akka/stream/impl/Stages.scala b/akka-stream/src/main/scala/akka/stream/impl/Stages.scala
  2918. index f3ce424bd2..573c9e4ff8 100644
  2919. --- a/akka-stream/src/main/scala/akka/stream/impl/Stages.scala
  2920. +++ b/akka-stream/src/main/scala/akka/stream/impl/Stages.scala
  2921. @@ -6,6 +6,7 @@ package akka.stream.impl
  2922. import akka.annotation.InternalApi
  2923. import akka.stream.Attributes._
  2924. import akka.stream._
  2925. +import akka.stream.ActorAttributes.Dispatcher
  2926.  
  2927. /**
  2928. * INTERNAL API
  2929. @@ -14,126 +15,126 @@ import akka.stream._
  2930.  
  2931. object DefaultAttributes {
  2932. // reusable common attributes
  2933. - val IODispatcher = ActorAttributes.IODispatcher
  2934. - val inputBufferOne = inputBuffer(initial = 1, max = 1)
  2935. + val IODispatcher: Dispatcher = ActorAttributes.IODispatcher
  2936. + val inputBufferOne: Attributes = inputBuffer(initial = 1, max = 1)
  2937.  
  2938. // stage specific default attributes
  2939. - val fused = name("fused")
  2940. - val materializedValueSource = name("matValueSource")
  2941. - val map = name("map")
  2942. - val log = name("log")
  2943. - val filter = name("filter")
  2944. - val filterNot = name("filterNot")
  2945. - val collect = name("collect")
  2946. - val recover = name("recover")
  2947. - val mapAsync = name("mapAsync")
  2948. - val mapAsyncUnordered = name("mapAsyncUnordered")
  2949. - val grouped = name("grouped")
  2950. - val groupedWithin = name("groupedWithin")
  2951. - val groupedWeightedWithin = name("groupedWeightedWithin")
  2952. - val limit = name("limit")
  2953. - val limitWeighted = name("limitWeighted")
  2954. - val sliding = name("sliding")
  2955. - val take = name("take")
  2956. - val drop = name("drop")
  2957. - val takeWhile = name("takeWhile")
  2958. - val dropWhile = name("dropWhile")
  2959. - val scan = name("scan")
  2960. - val scanAsync = name("scanAsync")
  2961. - val fold = name("fold")
  2962. - val foldAsync = name("foldAsync")
  2963. - val reduce = name("reduce")
  2964. - val intersperse = name("intersperse")
  2965. - val buffer = name("buffer")
  2966. - val conflate = name("conflate")
  2967. - val batch = name("batch")
  2968. - val batchWeighted = name("batchWeighted")
  2969. - val expand = name("expand")
  2970. - val statefulMapConcat = name("statefulMapConcat")
  2971. - val detacher = name("detacher")
  2972. - val groupBy = name("groupBy")
  2973. - val prefixAndTail = name("prefixAndTail")
  2974. - val split = name("split")
  2975. - val concatAll = name("concatAll")
  2976. - val processor = name("processor")
  2977. - val processorWithKey = name("processorWithKey")
  2978. - val identityOp = name("identityOp")
  2979. - val delimiterFraming = name("delimiterFraming")
  2980. + val fused: Attributes = name("fused")
  2981. + val materializedValueSource: Attributes = name("matValueSource")
  2982. + val map: Attributes = name("map")
  2983. + val log: Attributes = name("log")
  2984. + val filter: Attributes = name("filter")
  2985. + val filterNot: Attributes = name("filterNot")
  2986. + val collect: Attributes = name("collect")
  2987. + val recover: Attributes = name("recover")
  2988. + val mapAsync: Attributes = name("mapAsync")
  2989. + val mapAsyncUnordered: Attributes = name("mapAsyncUnordered")
  2990. + val grouped: Attributes = name("grouped")
  2991. + val groupedWithin: Attributes = name("groupedWithin")
  2992. + val groupedWeightedWithin: Attributes = name("groupedWeightedWithin")
  2993. + val limit: Attributes = name("limit")
  2994. + val limitWeighted: Attributes = name("limitWeighted")
  2995. + val sliding: Attributes = name("sliding")
  2996. + val take: Attributes = name("take")
  2997. + val drop: Attributes = name("drop")
  2998. + val takeWhile: Attributes = name("takeWhile")
  2999. + val dropWhile: Attributes = name("dropWhile")
  3000. + val scan: Attributes = name("scan")
  3001. + val scanAsync: Attributes = name("scanAsync")
  3002. + val fold: Attributes = name("fold")
  3003. + val foldAsync: Attributes = name("foldAsync")
  3004. + val reduce: Attributes = name("reduce")
  3005. + val intersperse: Attributes = name("intersperse")
  3006. + val buffer: Attributes = name("buffer")
  3007. + val conflate: Attributes = name("conflate")
  3008. + val batch: Attributes = name("batch")
  3009. + val batchWeighted: Attributes = name("batchWeighted")
  3010. + val expand: Attributes = name("expand")
  3011. + val statefulMapConcat: Attributes = name("statefulMapConcat")
  3012. + val detacher: Attributes = name("detacher")
  3013. + val groupBy: Attributes = name("groupBy")
  3014. + val prefixAndTail: Attributes = name("prefixAndTail")
  3015. + val split: Attributes = name("split")
  3016. + val concatAll: Attributes = name("concatAll")
  3017. + val processor: Attributes = name("processor")
  3018. + val processorWithKey: Attributes = name("processorWithKey")
  3019. + val identityOp: Attributes = name("identityOp")
  3020. + val delimiterFraming: Attributes = name("delimiterFraming")
  3021.  
  3022. - val initial = name("initial")
  3023. - val completion = name("completion")
  3024. - val idle = name("idle")
  3025. - val idleTimeoutBidi = name("idleTimeoutBidi")
  3026. - val delayInitial = name("delayInitial")
  3027. - val idleInject = name("idleInject")
  3028. - val backpressureTimeout = name("backpressureTimeout")
  3029. + val initial: Attributes = name("initial")
  3030. + val completion: Attributes = name("completion")
  3031. + val idle: Attributes = name("idle")
  3032. + val idleTimeoutBidi: Attributes = name("idleTimeoutBidi")
  3033. + val delayInitial: Attributes = name("delayInitial")
  3034. + val idleInject: Attributes = name("idleInject")
  3035. + val backpressureTimeout: Attributes = name("backpressureTimeout")
  3036.  
  3037. - val merge = name("merge")
  3038. - val mergePreferred = name("mergePreferred")
  3039. - val mergePrioritized = name("mergePrioritized")
  3040. - val flattenMerge = name("flattenMerge")
  3041. - val recoverWith = name("recoverWith")
  3042. - val broadcast = name("broadcast")
  3043. - val balance = name("balance")
  3044. - val zip = name("zip")
  3045. - val zipN = name("zipN")
  3046. - val zipWithN = name("zipWithN")
  3047. - val zipWithIndex = name("zipWithIndex")
  3048. - val unzip = name("unzip")
  3049. - val concat = name("concat")
  3050. - val orElse = name("orElse")
  3051. - val repeat = name("repeat")
  3052. - val unfold = name("unfold")
  3053. - val unfoldAsync = name("unfoldAsync")
  3054. - val delay = name("delay")
  3055. + val merge: Attributes = name("merge")
  3056. + val mergePreferred: Attributes = name("mergePreferred")
  3057. + val mergePrioritized: Attributes = name("mergePrioritized")
  3058. + val flattenMerge: Attributes = name("flattenMerge")
  3059. + val recoverWith: Attributes = name("recoverWith")
  3060. + val broadcast: Attributes = name("broadcast")
  3061. + val balance: Attributes = name("balance")
  3062. + val zip: Attributes = name("zip")
  3063. + val zipN: Attributes = name("zipN")
  3064. + val zipWithN: Attributes = name("zipWithN")
  3065. + val zipWithIndex: Attributes = name("zipWithIndex")
  3066. + val unzip: Attributes = name("unzip")
  3067. + val concat: Attributes = name("concat")
  3068. + val orElse: Attributes = name("orElse")
  3069. + val repeat: Attributes = name("repeat")
  3070. + val unfold: Attributes = name("unfold")
  3071. + val unfoldAsync: Attributes = name("unfoldAsync")
  3072. + val delay: Attributes = name("delay")
  3073.  
  3074. - val terminationWatcher = name("terminationWatcher")
  3075. + val terminationWatcher: Attributes = name("terminationWatcher")
  3076.  
  3077. - val publisherSource = name("publisherSource")
  3078. - val iterableSource = name("iterableSource")
  3079. - val cycledSource = name("cycledSource")
  3080. - val futureSource = name("futureSource")
  3081. - val futureFlattenSource = name("futureFlattenSource")
  3082. - val tickSource = name("tickSource")
  3083. - val singleSource = name("singleSource")
  3084. - val emptySource = name("emptySource")
  3085. - val maybeSource = name("MaybeSource")
  3086. - val failedSource = name("failedSource")
  3087. - val concatSource = name("concatSource")
  3088. - val concatMatSource = name("concatMatSource")
  3089. - val subscriberSource = name("subscriberSource")
  3090. - val actorPublisherSource = name("actorPublisherSource")
  3091. - val actorRefSource = name("actorRefSource")
  3092. - val queueSource = name("queueSource")
  3093. - val inputStreamSource = name("inputStreamSource") and IODispatcher
  3094. - val outputStreamSource = name("outputStreamSource") and IODispatcher
  3095. - val fileSource = name("fileSource") and IODispatcher
  3096. - val unfoldResourceSource = name("unfoldResourceSource") and IODispatcher
  3097. - val unfoldResourceSourceAsync = name("unfoldResourceSourceAsync") and IODispatcher
  3098. - val asJavaStream = name("asJavaStream") and IODispatcher
  3099. - val javaCollectorParallelUnordered = name("javaCollectorParallelUnordered")
  3100. - val javaCollector = name("javaCollector")
  3101. + val publisherSource: Attributes = name("publisherSource")
  3102. + val iterableSource: Attributes = name("iterableSource")
  3103. + val cycledSource: Attributes = name("cycledSource")
  3104. + val futureSource: Attributes = name("futureSource")
  3105. + val futureFlattenSource: Attributes = name("futureFlattenSource")
  3106. + val tickSource: Attributes = name("tickSource")
  3107. + val singleSource: Attributes = name("singleSource")
  3108. + val emptySource: Attributes = name("emptySource")
  3109. + val maybeSource: Attributes = name("MaybeSource")
  3110. + val failedSource: Attributes = name("failedSource")
  3111. + val concatSource: Attributes = name("concatSource")
  3112. + val concatMatSource: Attributes = name("concatMatSource")
  3113. + val subscriberSource: Attributes = name("subscriberSource")
  3114. + val actorPublisherSource: Attributes = name("actorPublisherSource")
  3115. + val actorRefSource: Attributes = name("actorRefSource")
  3116. + val queueSource: Attributes = name("queueSource")
  3117. + val inputStreamSource: Attributes = name("inputStreamSource") and IODispatcher
  3118. + val outputStreamSource: Attributes = name("outputStreamSource") and IODispatcher
  3119. + val fileSource: Attributes = name("fileSource") and IODispatcher
  3120. + val unfoldResourceSource: Attributes = name("unfoldResourceSource") and IODispatcher
  3121. + val unfoldResourceSourceAsync: Attributes = name("unfoldResourceSourceAsync") and IODispatcher
  3122. + val asJavaStream: Attributes = name("asJavaStream") and IODispatcher
  3123. + val javaCollectorParallelUnordered: Attributes = name("javaCollectorParallelUnordered")
  3124. + val javaCollector: Attributes = name("javaCollector")
  3125.  
  3126. - val subscriberSink = name("subscriberSink")
  3127. - val cancelledSink = name("cancelledSink")
  3128. - val headSink = name("headSink") and inputBufferOne
  3129. - val headOptionSink = name("headOptionSink") and inputBufferOne
  3130. - val lastSink = name("lastSink")
  3131. - val lastOptionSink = name("lastOptionSink")
  3132. - val seqSink = name("seqSink")
  3133. - val publisherSink = name("publisherSink")
  3134. - val fanoutPublisherSink = name("fanoutPublisherSink")
  3135. - val ignoreSink = name("ignoreSink")
  3136. - val actorRefSink = name("actorRefSink")
  3137. - val actorRefWithAck = name("actorRefWithAckSink")
  3138. - val actorSubscriberSink = name("actorSubscriberSink")
  3139. - val queueSink = name("queueSink")
  3140. - val lazySink = name("lazySink")
  3141. - val lazySource = name("lazySource")
  3142. - val outputStreamSink = name("outputStreamSink") and IODispatcher
  3143. - val inputStreamSink = name("inputStreamSink") and IODispatcher
  3144. - val fileSink = name("fileSink") and IODispatcher
  3145. - val fromJavaStream = name("fromJavaStream")
  3146. + val subscriberSink: Attributes = name("subscriberSink")
  3147. + val cancelledSink: Attributes = name("cancelledSink")
  3148. + val headSink: Attributes = name("headSink") and inputBufferOne
  3149. + val headOptionSink: Attributes = name("headOptionSink") and inputBufferOne
  3150. + val lastSink: Attributes = name("lastSink")
  3151. + val lastOptionSink: Attributes = name("lastOptionSink")
  3152. + val seqSink: Attributes = name("seqSink")
  3153. + val publisherSink: Attributes = name("publisherSink")
  3154. + val fanoutPublisherSink: Attributes = name("fanoutPublisherSink")
  3155. + val ignoreSink: Attributes = name("ignoreSink")
  3156. + val actorRefSink: Attributes = name("actorRefSink")
  3157. + val actorRefWithAck: Attributes = name("actorRefWithAckSink")
  3158. + val actorSubscriberSink: Attributes = name("actorSubscriberSink")
  3159. + val queueSink: Attributes = name("queueSink")
  3160. + val lazySink: Attributes = name("lazySink")
  3161. + val lazySource: Attributes = name("lazySource")
  3162. + val outputStreamSink: Attributes = name("outputStreamSink") and IODispatcher
  3163. + val inputStreamSink: Attributes = name("inputStreamSink") and IODispatcher
  3164. + val fileSink: Attributes = name("fileSink") and IODispatcher
  3165. + val fromJavaStream: Attributes = name("fromJavaStream")
  3166. }
  3167.  
  3168. }
  3169. diff --git a/akka-stream/src/main/scala/akka/stream/impl/StreamLayout.scala b/akka-stream/src/main/scala/akka/stream/impl/StreamLayout.scala
  3170. index 5783f58ced..05d1a08d6e 100644
  3171. --- a/akka-stream/src/main/scala/akka/stream/impl/StreamLayout.scala
  3172. +++ b/akka-stream/src/main/scala/akka/stream/impl/StreamLayout.scala
  3173. @@ -34,11 +34,11 @@ import scala.util.control.NonFatal
  3174. */
  3175. @InternalApi private[stream] object VirtualProcessor {
  3176. case object Inert {
  3177. - val subscriber = new CancellingSubscriber[Any]
  3178. + val subscriber: CancellingSubscriber[Any] = new CancellingSubscriber[Any]
  3179. }
  3180. case class Both(subscriber: Subscriber[Any])
  3181. object Both {
  3182. - def create(s: Subscriber[_]) = Both(s.asInstanceOf[Subscriber[Any]])
  3183. + def create(s: Subscriber[_]): Both = Both(s.asInstanceOf[Subscriber[Any]])
  3184. }
  3185. }
  3186.  
  3187. @@ -250,7 +250,7 @@ import scala.util.control.NonFatal
  3188. case object PassThrough extends SubscriptionState { override def demand: Long = 0 }
  3189. case class Buffering(demand: Long) extends SubscriptionState
  3190.  
  3191. - val NoBufferedDemand = Buffering(0)
  3192. + val NoBufferedDemand: WrappedSubscription.Buffering = Buffering(0)
  3193. }
  3194.  
  3195. // Extdending AtomicReference to make the hot memory location share the same cache line with the Subscription
  3196. @@ -361,11 +361,11 @@ import scala.util.control.NonFatal
  3197. @InternalApi private[akka] final case class ProcessorModule[In, Out, Mat](
  3198. val createProcessor: () ⇒ (Processor[In, Out], Mat),
  3199. attributes: Attributes = DefaultAttributes.processor) extends StreamLayout.AtomicModule[FlowShape[In, Out], Mat] {
  3200. - val inPort = Inlet[In]("ProcessorModule.in")
  3201. - val outPort = Outlet[Out]("ProcessorModule.out")
  3202. - override val shape = new FlowShape(inPort, outPort)
  3203. + val inPort: Inlet[In] = Inlet[In]("ProcessorModule.in")
  3204. + val outPort: Outlet[Out] = Outlet[Out]("ProcessorModule.out")
  3205. + override val shape: FlowShape[In, Out] = new FlowShape(inPort, outPort)
  3206.  
  3207. - override def withAttributes(attributes: Attributes) = copy(attributes = attributes)
  3208. + override def withAttributes(attributes: Attributes): ProcessorModule[In, Out, Mat] = copy(attributes = attributes)
  3209. override def toString: String = f"ProcessorModule [${System.identityHashCode(this)}%08x]"
  3210.  
  3211. override private[stream] def traversalBuilder =
  3212. diff --git a/akka-stream/src/main/scala/akka/stream/impl/SubscriberManagement.scala b/akka-stream/src/main/scala/akka/stream/impl/SubscriberManagement.scala
  3213. index 3b673a3062..28250ac0ae 100644
  3214. --- a/akka-stream/src/main/scala/akka/stream/impl/SubscriberManagement.scala
  3215. +++ b/akka-stream/src/main/scala/akka/stream/impl/SubscriberManagement.scala
  3216. @@ -30,7 +30,7 @@ private[akka] object SubscriberManagement {
  3217. def apply[T](subscriber: Subscriber[T]): Unit = tryOnError(subscriber, cause)
  3218. }
  3219.  
  3220. - val ShutDown = new ErrorCompleted(ActorPublisher.NormalShutdownReason)
  3221. + val ShutDown: ErrorCompleted = new ErrorCompleted(ActorPublisher.NormalShutdownReason)
  3222. }
  3223.  
  3224. /**
  3225. @@ -96,7 +96,7 @@ private[akka] trait SubscriberManagement[T] extends ResizableMultiReaderRingBuff
  3226. // if non-null, holds the end-of-stream state
  3227. private[this] var endOfStream: EndOfStream = NotReached
  3228.  
  3229. - def cursors = subscriptions
  3230. + def cursors: SubscriberManagement.this.Subscriptions = subscriptions
  3231.  
  3232. /**
  3233. * more demand was signaled from a given subscriber
  3234. diff --git a/akka-stream/src/main/scala/akka/stream/impl/Throttle.scala b/akka-stream/src/main/scala/akka/stream/impl/Throttle.scala
  3235. index d909f16043..82e597616b 100644
  3236. --- a/akka-stream/src/main/scala/akka/stream/impl/Throttle.scala
  3237. +++ b/akka-stream/src/main/scala/akka/stream/impl/Throttle.scala
  3238. @@ -38,7 +38,7 @@ import scala.concurrent.duration.{ FiniteDuration, _ }
  3239.  
  3240. var willStop = false
  3241. var currentElement: T = _
  3242. - val enforcing = mode match {
  3243. + val enforcing: Boolean = mode match {
  3244. case Enforcing ⇒ true
  3245. case Shaping ⇒ false
  3246. }
  3247. diff --git a/akka-stream/src/main/scala/akka/stream/impl/Timers.scala b/akka-stream/src/main/scala/akka/stream/impl/Timers.scala
  3248. index 53b74ee9e6..1bcbc70cde 100644
  3249. --- a/akka-stream/src/main/scala/akka/stream/impl/Timers.scala
  3250. +++ b/akka-stream/src/main/scala/akka/stream/impl/Timers.scala
  3251. @@ -33,7 +33,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
  3252. }
  3253.  
  3254. final class Initial[T](val timeout: FiniteDuration) extends SimpleLinearGraphStage[T] {
  3255. - override def initialAttributes = DefaultAttributes.initial
  3256. + override def initialAttributes: Attributes = DefaultAttributes.initial
  3257.  
  3258. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  3259. new TimerGraphStageLogic(shape) with InHandler with OutHandler {
  3260. @@ -60,7 +60,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
  3261. }
  3262.  
  3263. final class Completion[T](val timeout: FiniteDuration) extends SimpleLinearGraphStage[T] {
  3264. - override def initialAttributes = DefaultAttributes.completion
  3265. + override def initialAttributes: Attributes = DefaultAttributes.completion
  3266.  
  3267. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  3268. new TimerGraphStageLogic(shape) with InHandler with OutHandler {
  3269. @@ -81,7 +81,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
  3270. }
  3271.  
  3272. final class Idle[T](val timeout: FiniteDuration) extends SimpleLinearGraphStage[T] {
  3273. - override def initialAttributes = DefaultAttributes.idle
  3274. + override def initialAttributes: Attributes = DefaultAttributes.idle
  3275.  
  3276. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  3277. new TimerGraphStageLogic(shape) with InHandler with OutHandler {
  3278. @@ -108,7 +108,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
  3279. }
  3280.  
  3281. final class BackpressureTimeout[T](val timeout: FiniteDuration) extends SimpleLinearGraphStage[T] {
  3282. - override def initialAttributes = DefaultAttributes.backpressureTimeout
  3283. + override def initialAttributes: Attributes = DefaultAttributes.backpressureTimeout
  3284.  
  3285. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  3286. new TimerGraphStageLogic(shape) with InHandler with OutHandler {
  3287. @@ -140,13 +140,13 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
  3288. }
  3289.  
  3290. final class IdleTimeoutBidi[I, O](val timeout: FiniteDuration) extends GraphStage[BidiShape[I, I, O, O]] {
  3291. - val in1 = Inlet[I]("in1")
  3292. - val in2 = Inlet[O]("in2")
  3293. - val out1 = Outlet[I]("out1")
  3294. - val out2 = Outlet[O]("out2")
  3295. - val shape = BidiShape(in1, out1, in2, out2)
  3296. + val in1: Inlet[I] = Inlet[I]("in1")
  3297. + val in2: Inlet[O] = Inlet[O]("in2")
  3298. + val out1: Outlet[I] = Outlet[I]("out1")
  3299. + val out2: Outlet[O] = Outlet[O]("out2")
  3300. + val shape: BidiShape[I, I, O, O] = BidiShape(in1, out1, in2, out2)
  3301.  
  3302. - override def initialAttributes = DefaultAttributes.idleTimeoutBidi
  3303. + override def initialAttributes: Attributes = DefaultAttributes.idleTimeoutBidi
  3304.  
  3305. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new TimerGraphStageLogic(shape) {
  3306. private var nextDeadline: Long = System.nanoTime + timeout.toNanos
  3307. @@ -178,7 +178,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
  3308. }
  3309.  
  3310. final class DelayInitial[T](val delay: FiniteDuration) extends SimpleLinearGraphStage[T] {
  3311. - override def initialAttributes = DefaultAttributes.delayInitial
  3312. + override def initialAttributes: Attributes = DefaultAttributes.delayInitial
  3313.  
  3314. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  3315. new TimerGraphStageLogic(shape) with InHandler with OutHandler {
  3316. @@ -209,7 +209,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
  3317. val in: Inlet[I] = Inlet("IdleInject.in")
  3318. val out: Outlet[O] = Outlet("IdleInject.out")
  3319.  
  3320. - override def initialAttributes = DefaultAttributes.idleInject
  3321. + override def initialAttributes: Attributes = DefaultAttributes.idleInject
  3322.  
  3323. override val shape: FlowShape[I, O] = FlowShape(in, out)
  3324.  
  3325. diff --git a/akka-stream/src/main/scala/akka/stream/impl/Transfer.scala b/akka-stream/src/main/scala/akka/stream/impl/Transfer.scala
  3326. index d950d58e38..b0cf33d074 100644
  3327. --- a/akka-stream/src/main/scala/akka/stream/impl/Transfer.scala
  3328. +++ b/akka-stream/src/main/scala/akka/stream/impl/Transfer.scala
  3329. @@ -45,11 +45,11 @@ import akka.annotation.InternalApi
  3330. */
  3331. @InternalApi private[akka] trait DefaultInputTransferStates extends Inputs {
  3332. override val NeedsInput: TransferState = new TransferState {
  3333. - def isReady = inputsAvailable
  3334. - def isCompleted = inputsDepleted
  3335. + def isReady: Boolean = inputsAvailable
  3336. + def isCompleted: Boolean = inputsDepleted
  3337. }
  3338. override val NeedsInputOrComplete: TransferState = new TransferState {
  3339. - def isReady = inputsAvailable || inputsDepleted
  3340. + def isReady: Boolean = inputsAvailable || inputsDepleted
  3341. def isCompleted = false
  3342. }
  3343. }
  3344. @@ -81,11 +81,11 @@ import akka.annotation.InternalApi
  3345. */
  3346. @InternalApi private[akka] trait DefaultOutputTransferStates extends Outputs {
  3347. override val NeedsDemand: TransferState = new TransferState {
  3348. - def isReady = demandAvailable
  3349. - def isCompleted = isClosed
  3350. + def isReady: Boolean = demandAvailable
  3351. + def isCompleted: Boolean = isClosed
  3352. }
  3353. override def NeedsDemandOrCancel: TransferState = new TransferState {
  3354. - def isReady = demandAvailable || isClosed
  3355. + def isReady: Boolean = demandAvailable || isClosed
  3356. def isCompleted = false
  3357. }
  3358. }
  3359. @@ -97,7 +97,7 @@ import akka.annotation.InternalApi
  3360. @InternalApi private[akka] trait TransferState {
  3361. def isReady: Boolean
  3362. def isCompleted: Boolean
  3363. - def isExecutable = isReady && !isCompleted
  3364. + def isExecutable: Boolean = isReady && !isCompleted
  3365.  
  3366. def ||(other: TransferState): TransferState = new TransferState {
  3367. def isReady: Boolean = TransferState.this.isReady || other.isReady
  3368. @@ -189,7 +189,7 @@ import akka.annotation.InternalApi
  3369.  
  3370. final def isPumpFinished: Boolean = transferState.isCompleted
  3371.  
  3372. - protected final val completedPhase = TransferPhase(Completed) {
  3373. + protected final val completedPhase: TransferPhase = TransferPhase(Completed) {
  3374. () ⇒ throw new IllegalStateException("The action of completed phase must be never executed")
  3375. }
  3376.  
  3377. diff --git a/akka-stream/src/main/scala/akka/stream/impl/TraversalBuilder.scala b/akka-stream/src/main/scala/akka/stream/impl/TraversalBuilder.scala
  3378. index a9f99c9f6c..ce0fcd789d 100644
  3379. --- a/akka-stream/src/main/scala/akka/stream/impl/TraversalBuilder.scala
  3380. +++ b/akka-stream/src/main/scala/akka/stream/impl/TraversalBuilder.scala
  3381. @@ -1076,7 +1076,7 @@ import scala.collection.immutable.Map.Map1
  3382. * See comments in akka.stream.impl.package for more details.
  3383. */
  3384. @InternalApi private[akka] final class BuilderKey extends TraversalBuildStep {
  3385. - override def toString = s"K:$hashCode"
  3386. + override def toString: String = s"K:$hashCode"
  3387. }
  3388.  
  3389. /**
  3390. diff --git a/akka-stream/src/main/scala/akka/stream/impl/Unfold.scala b/akka-stream/src/main/scala/akka/stream/impl/Unfold.scala
  3391. index 1ccf76d98a..4c4414b36a 100644
  3392. --- a/akka-stream/src/main/scala/akka/stream/impl/Unfold.scala
  3393. +++ b/akka-stream/src/main/scala/akka/stream/impl/Unfold.scala
  3394. @@ -46,7 +46,7 @@ import scala.util.{ Failure, Success, Try }
  3395. private[this] var state = s
  3396. private[this] var asyncHandler: Function1[Try[Option[(S, E)]], Unit] = _
  3397.  
  3398. - override def preStart() = {
  3399. + override def preStart(): Unit = {
  3400. val ac = getAsyncCallback[Try[Option[(S, E)]]] {
  3401. case Failure(ex) ⇒ fail(out, ex)
  3402. case Success(None) ⇒ complete(out)
  3403. diff --git a/akka-stream/src/main/scala/akka/stream/impl/UnfoldResourceSource.scala b/akka-stream/src/main/scala/akka/stream/impl/UnfoldResourceSource.scala
  3404. index 296e5a3fa2..17d331247d 100644
  3405. --- a/akka-stream/src/main/scala/akka/stream/impl/UnfoldResourceSource.scala
  3406. +++ b/akka-stream/src/main/scala/akka/stream/impl/UnfoldResourceSource.scala
  3407. @@ -11,6 +11,7 @@ import akka.stream.stage._
  3408.  
  3409. import scala.annotation.tailrec
  3410. import scala.util.control.NonFatal
  3411. +import akka.stream.Supervision.Decider
  3412.  
  3413. /**
  3414. * INTERNAL API
  3415. @@ -19,12 +20,12 @@ import scala.util.control.NonFatal
  3416. create: () ⇒ S,
  3417. readData: (S) ⇒ Option[T],
  3418. close: (S) ⇒ Unit) extends GraphStage[SourceShape[T]] {
  3419. - val out = Outlet[T]("UnfoldResourceSource.out")
  3420. - override val shape = SourceShape(out)
  3421. + val out: Outlet[T] = Outlet[T]("UnfoldResourceSource.out")
  3422. + override val shape: SourceShape[T] = SourceShape(out)
  3423. override def initialAttributes: Attributes = DefaultAttributes.unfoldResourceSource
  3424.  
  3425. - def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) with OutHandler {
  3426. - lazy val decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3427. + def createLogic(inheritedAttributes: Attributes): GraphStageLogic with OutHandler = new GraphStageLogic(shape) with OutHandler {
  3428. + lazy val decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3429. var open = false
  3430. var blockingStream: S = _
  3431. setHandler(out, this)
  3432. diff --git a/akka-stream/src/main/scala/akka/stream/impl/UnfoldResourceSourceAsync.scala b/akka-stream/src/main/scala/akka/stream/impl/UnfoldResourceSourceAsync.scala
  3433. index dfc8f0e03a..03aab78cc9 100644
  3434. --- a/akka-stream/src/main/scala/akka/stream/impl/UnfoldResourceSourceAsync.scala
  3435. +++ b/akka-stream/src/main/scala/akka/stream/impl/UnfoldResourceSourceAsync.scala
  3436. @@ -13,6 +13,7 @@ import akka.stream.stage._
  3437. import scala.concurrent.Future
  3438. import scala.util.{ Failure, Success, Try }
  3439. import scala.util.control.NonFatal
  3440. +import akka.stream.Supervision.Decider
  3441.  
  3442. /**
  3443. * INTERNAL API
  3444. @@ -21,12 +22,12 @@ import scala.util.control.NonFatal
  3445. create: () ⇒ Future[S],
  3446. readData: (S) ⇒ Future[Option[T]],
  3447. close: (S) ⇒ Future[Done]) extends GraphStage[SourceShape[T]] {
  3448. - val out = Outlet[T]("UnfoldResourceSourceAsync.out")
  3449. - override val shape = SourceShape(out)
  3450. + val out: Outlet[T] = Outlet[T]("UnfoldResourceSourceAsync.out")
  3451. + override val shape: SourceShape[T] = SourceShape(out)
  3452. override def initialAttributes: Attributes = DefaultAttributes.unfoldResourceSourceAsync
  3453.  
  3454. - def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) with OutHandler {
  3455. - lazy val decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3456. + def createLogic(inheritedAttributes: Attributes): GraphStageLogic with OutHandler = new GraphStageLogic(shape) with OutHandler {
  3457. + lazy val decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3458. private implicit def ec = ActorMaterializerHelper.downcast(materializer).system.dispatcher
  3459. private var state: Option[S] = None
  3460.  
  3461. diff --git a/akka-stream/src/main/scala/akka/stream/impl/fusing/ActorGraphInterpreter.scala b/akka-stream/src/main/scala/akka/stream/impl/fusing/ActorGraphInterpreter.scala
  3462. index f845ab9371..53b66ed68c 100644
  3463. --- a/akka-stream/src/main/scala/akka/stream/impl/fusing/ActorGraphInterpreter.scala
  3464. +++ b/akka-stream/src/main/scala/akka/stream/impl/fusing/ActorGraphInterpreter.scala
  3465. @@ -23,6 +23,7 @@ import scala.annotation.tailrec
  3466. import scala.collection.immutable
  3467. import scala.concurrent.Promise
  3468. import scala.util.control.NonFatal
  3469. +import akka.event.LoggingAdapter
  3470.  
  3471. /**
  3472. * INTERNAL API
  3473. @@ -331,7 +332,7 @@ import scala.util.control.NonFatal
  3474. val in: Inlet[Any] = Inlet[Any]("UpstreamBoundary:" + internalPortName)
  3475. in.id = 0
  3476.  
  3477. - val publisher = new OutputBoundaryPublisher(this, internalPortName)
  3478. + val publisher: OutputBoundaryPublisher = new OutputBoundaryPublisher(this, internalPortName)
  3479.  
  3480. @volatile private var actor: ActorRef = null
  3481. def setActor(actor: ActorRef): Unit = this.actor = actor
  3482. @@ -401,7 +402,7 @@ import scala.util.control.NonFatal
  3483. val subscription = new Subscription {
  3484. override def request(elements: Long): Unit = actor ! RequestMore(ActorOutputBoundary.this, elements)
  3485. override def cancel(): Unit = actor ! Cancel(ActorOutputBoundary.this)
  3486. - override def toString = s"BoundarySubscription[$actor, $internalPortName]"
  3487. + override def toString: String = s"BoundarySubscription[$actor, $internalPortName]"
  3488. }
  3489.  
  3490. tryOnSubscribe(subscriber, subscription)
  3491. @@ -448,7 +449,7 @@ import scala.util.control.NonFatal
  3492. import ActorGraphInterpreter._
  3493.  
  3494. private var self: ActorRef = _
  3495. - lazy val log = Logging(mat.system.eventStream, self)
  3496. + lazy val log: LoggingAdapter = Logging(mat.system.eventStream, self)
  3497.  
  3498. /**
  3499. * @param promise Will be completed upon processing the event, or failed if processing the event throws
  3500. @@ -525,7 +526,7 @@ import scala.util.control.NonFatal
  3501. * because no data can enter “fast enough” from the outside
  3502. */
  3503. // TODO: Fix event limit heuristic
  3504. - val shellEventLimit = attributes.mandatoryAttribute[Attributes.InputBuffer].max * 16
  3505. + val shellEventLimit: Int = attributes.mandatoryAttribute[Attributes.InputBuffer].max * 16
  3506. // Limits the number of events processed by the interpreter on an abort event.
  3507. // TODO: Better heuristic here
  3508. private val abortLimit = shellEventLimit * 2
  3509. @@ -571,7 +572,7 @@ import scala.util.control.NonFatal
  3510.  
  3511. private var waitingForShutdown: Boolean = false
  3512.  
  3513. - val resume = ResumeShell(this)
  3514. + val resume: GraphInterpreterShell.this.ResumeShell = ResumeShell(this)
  3515.  
  3516. def sendResume(sendResume: Boolean): Unit = {
  3517. resumeScheduled = true
  3518. @@ -667,9 +668,9 @@ import scala.util.control.NonFatal
  3519. @InternalApi private[akka] final class ActorGraphInterpreter(_initial: GraphInterpreterShell) extends Actor with ActorLogging {
  3520. import ActorGraphInterpreter._
  3521.  
  3522. - var activeInterpreters = Set.empty[GraphInterpreterShell]
  3523. + var activeInterpreters: Set[GraphInterpreterShell] = Set.empty[GraphInterpreterShell]
  3524. var newShells: List[GraphInterpreterShell] = Nil
  3525. - val subFusingMaterializerImpl = new SubFusingActorMaterializerImpl(_initial.mat, registerShell)
  3526. + val subFusingMaterializerImpl: SubFusingActorMaterializerImpl = new SubFusingActorMaterializerImpl(_initial.mat, registerShell)
  3527.  
  3528. def tryInit(shell: GraphInterpreterShell): Boolean =
  3529. try {
  3530. diff --git a/akka-stream/src/main/scala/akka/stream/impl/fusing/GraphInterpreter.scala b/akka-stream/src/main/scala/akka/stream/impl/fusing/GraphInterpreter.scala
  3531. index d5fbae163f..b033695680 100644
  3532. --- a/akka-stream/src/main/scala/akka/stream/impl/fusing/GraphInterpreter.scala
  3533. +++ b/akka-stream/src/main/scala/akka/stream/impl/fusing/GraphInterpreter.scala
  3534. @@ -84,7 +84,7 @@ import scala.util.control.NonFatal
  3535. var portState: Int = InReady
  3536. var slot: Any = Empty
  3537.  
  3538. - override def toString =
  3539. + override def toString: String =
  3540. if (GraphInterpreter.Debug) s"Connection($id, $inOwner, $outOwner, $inHandler, $outHandler, $portState, $slot)"
  3541. else s"Connection($id, $portState, $slot, $inHandler, $outHandler)"
  3542. }
  3543. @@ -95,7 +95,7 @@ import scala.util.control.NonFatal
  3544. * when this accidentally leaks onto threads that are not stopped when this
  3545. * class should be unloaded.
  3546. */
  3547. - override def initialValue = new Array(1)
  3548. + override def initialValue: Array[AnyRef] = new Array(1)
  3549. }
  3550.  
  3551. /**
  3552. diff --git a/akka-stream/src/main/scala/akka/stream/impl/fusing/GraphStages.scala b/akka-stream/src/main/scala/akka/stream/impl/fusing/GraphStages.scala
  3553. index 92b5197a61..4d060574d7 100644
  3554. --- a/akka-stream/src/main/scala/akka/stream/impl/fusing/GraphStages.scala
  3555. +++ b/akka-stream/src/main/scala/akka/stream/impl/fusing/GraphStages.scala
  3556. @@ -51,13 +51,13 @@ import scala.util.control.NonFatal
  3557. * INTERNAL API
  3558. */
  3559. @InternalApi private[akka] abstract class SimpleLinearGraphStage[T] extends GraphStage[FlowShape[T, T]] {
  3560. - val in = Inlet[T](Logging.simpleName(this) + ".in")
  3561. - val out = Outlet[T](Logging.simpleName(this) + ".out")
  3562. - override val shape = FlowShape(in, out)
  3563. + val in: Inlet[T] = Inlet[T](Logging.simpleName(this) + ".in")
  3564. + val out: Outlet[T] = Outlet[T](Logging.simpleName(this) + ".out")
  3565. + override val shape: FlowShape[T, T] = FlowShape(in, out)
  3566. }
  3567.  
  3568. private object Identity extends SimpleLinearGraphStage[Any] {
  3569. - override def initialAttributes = DefaultAttributes.identityOp
  3570. + override def initialAttributes: Attributes = DefaultAttributes.identityOp
  3571.  
  3572. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with InHandler with OutHandler {
  3573. def onPush(): Unit = push(out, grab(in))
  3574. @@ -70,13 +70,13 @@ import scala.util.control.NonFatal
  3575. override def toString = "Identity"
  3576. }
  3577.  
  3578. - def identity[T] = Identity.asInstanceOf[SimpleLinearGraphStage[T]]
  3579. + def identity[T]: SimpleLinearGraphStage[T] = Identity.asInstanceOf[SimpleLinearGraphStage[T]]
  3580.  
  3581. /**
  3582. * INTERNAL API
  3583. */
  3584. @InternalApi private[akka] final class Detacher[T] extends SimpleLinearGraphStage[T] {
  3585. - override def initialAttributes = DefaultAttributes.detacher
  3586. + override def initialAttributes: Attributes = DefaultAttributes.detacher
  3587.  
  3588. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with InHandler with OutHandler {
  3589.  
  3590. @@ -111,9 +111,9 @@ import scala.util.control.NonFatal
  3591. def detacher[T]: GraphStage[FlowShape[T, T]] = _detacher.asInstanceOf[GraphStage[FlowShape[T, T]]]
  3592.  
  3593. private object TerminationWatcher extends GraphStageWithMaterializedValue[FlowShape[Any, Any], Future[Done]] {
  3594. - val in = Inlet[Any]("terminationWatcher.in")
  3595. - val out = Outlet[Any]("terminationWatcher.out")
  3596. - override val shape = FlowShape(in, out)
  3597. + val in: Inlet[Any] = Inlet[Any]("terminationWatcher.in")
  3598. + val out: Outlet[Any] = Outlet[Any]("terminationWatcher.out")
  3599. + override val shape: FlowShape[Any, Any] = FlowShape(in, out)
  3600. override def initialAttributes: Attributes = DefaultAttributes.terminationWatcher
  3601.  
  3602. override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, Future[Done]) = {
  3603. @@ -154,16 +154,16 @@ import scala.util.control.NonFatal
  3604. TerminationWatcher.asInstanceOf[GraphStageWithMaterializedValue[FlowShape[T, T], Future[Done]]]
  3605.  
  3606. private class FlowMonitorImpl[T] extends AtomicReference[Any](Initialized) with FlowMonitor[T] {
  3607. - override def state = get match {
  3608. + override def state: StreamState[T] = get match {
  3609. case s: StreamState[_] ⇒ s.asInstanceOf[StreamState[T]]
  3610. case msg ⇒ Received(msg.asInstanceOf[T])
  3611. }
  3612. }
  3613.  
  3614. private class MonitorFlow[T] extends GraphStageWithMaterializedValue[FlowShape[T, T], FlowMonitor[T]] {
  3615. - val in = Inlet[T]("FlowMonitor.in")
  3616. - val out = Outlet[T]("FlowMonitor.out")
  3617. - val shape = FlowShape.of(in, out)
  3618. + val in: Inlet[T] = Inlet[T]("FlowMonitor.in")
  3619. + val out: Outlet[T] = Outlet[T]("FlowMonitor.out")
  3620. + val shape: FlowShape[T, T] = FlowShape.of(in, out)
  3621.  
  3622. override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, FlowMonitor[T]) = {
  3623. val monitor: FlowMonitorImpl[T] = new FlowMonitorImpl[T]
  3624. @@ -232,16 +232,16 @@ import scala.util.control.NonFatal
  3625.  
  3626. final class TickSource[T](val initialDelay: FiniteDuration, val interval: FiniteDuration, val tick: T)
  3627. extends GraphStageWithMaterializedValue[SourceShape[T], Cancellable] {
  3628. - override val shape = SourceShape(Outlet[T]("TickSource.out"))
  3629. - val out = shape.out
  3630. + override val shape: SourceShape[T] = SourceShape(Outlet[T]("TickSource.out"))
  3631. + val out: Outlet[T] = shape.out
  3632. override def initialAttributes: Attributes = DefaultAttributes.tickSource
  3633. override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, Cancellable) = {
  3634.  
  3635. val logic = new TimerGraphStageLogic(shape) with Cancellable {
  3636. - val cancelled = new AtomicBoolean(false)
  3637. + val cancelled: AtomicBoolean = new AtomicBoolean(false)
  3638. val cancelCallback: AtomicReference[Option[AsyncCallback[Unit]]] = new AtomicReference(None)
  3639.  
  3640. - override def preStart() = {
  3641. + override def preStart(): Unit = {
  3642. cancelCallback.set(Some(getAsyncCallback[Unit](_ ⇒ completeStage())))
  3643. if (cancelled.get)
  3644. completeStage()
  3645. @@ -251,16 +251,16 @@ import scala.util.control.NonFatal
  3646.  
  3647. setHandler(out, eagerTerminateOutput)
  3648.  
  3649. - override protected def onTimer(timerKey: Any) =
  3650. + override protected def onTimer(timerKey: Any): Unit =
  3651. if (isAvailable(out) && !isCancelled) push(out, tick)
  3652.  
  3653. - override def cancel() = {
  3654. + override def cancel(): Boolean = {
  3655. val success = !cancelled.getAndSet(true)
  3656. if (success) cancelCallback.get.foreach(_.invoke(()))
  3657. success
  3658. }
  3659.  
  3660. - override def isCancelled = cancelled.get
  3661. + override def isCancelled: Boolean = cancelled.get
  3662.  
  3663. override def toString: String = "TickSourceLogic"
  3664. }
  3665. @@ -274,9 +274,9 @@ import scala.util.control.NonFatal
  3666. final class SingleSource[T](val elem: T) extends GraphStage[SourceShape[T]] {
  3667. override def initialAttributes: Attributes = DefaultAttributes.singleSource
  3668. ReactiveStreamsCompliance.requireNonNullElement(elem)
  3669. - val out = Outlet[T]("single.out")
  3670. - val shape = SourceShape(out)
  3671. - def createLogic(attr: Attributes) =
  3672. + val out: Outlet[T] = Outlet[T]("single.out")
  3673. + val shape: SourceShape[T] = SourceShape(out)
  3674. + def createLogic(attr: Attributes): GraphStageLogic with OutHandler =
  3675. new GraphStageLogic(shape) with OutHandler {
  3676. def onPull(): Unit = {
  3677. push(out, elem)
  3678. @@ -294,9 +294,9 @@ import scala.util.control.NonFatal
  3679. ReactiveStreamsCompliance.requireNonNullElement(futureSource)
  3680.  
  3681. val out: Outlet[T] = Outlet("FutureFlattenSource.out")
  3682. - override val shape = SourceShape(out)
  3683. + override val shape: SourceShape[T] = SourceShape(out)
  3684.  
  3685. - override def initialAttributes = DefaultAttributes.futureFlattenSource
  3686. + override def initialAttributes: Attributes = DefaultAttributes.futureFlattenSource
  3687.  
  3688. override def createLogicAndMaterializedValue(attr: Attributes): (GraphStageLogic, Future[M]) = {
  3689. val materialized = Promise[M]()
  3690. @@ -373,10 +373,10 @@ import scala.util.control.NonFatal
  3691.  
  3692. final class FutureSource[T](val future: Future[T]) extends GraphStage[SourceShape[T]] {
  3693. ReactiveStreamsCompliance.requireNonNullElement(future)
  3694. - val shape = SourceShape(Outlet[T]("FutureSource.out"))
  3695. - val out = shape.out
  3696. + val shape: SourceShape[T] = SourceShape(Outlet[T]("FutureSource.out"))
  3697. + val out: Outlet[T] = shape.out
  3698. override def initialAttributes: Attributes = DefaultAttributes.futureSource
  3699. - override def createLogic(attr: Attributes) =
  3700. + override def createLogic(attr: Attributes): GraphStageLogic with OutHandler =
  3701. new GraphStageLogic(shape) with OutHandler {
  3702. def onPull(): Unit = {
  3703. if (future.isCompleted) {
  3704. @@ -408,10 +408,10 @@ import scala.util.control.NonFatal
  3705. */
  3706. @InternalApi private[akka] object IgnoreSink extends GraphStageWithMaterializedValue[SinkShape[Any], Future[Done]] {
  3707.  
  3708. - val in = Inlet[Any]("Ignore.in")
  3709. - val shape = SinkShape(in)
  3710. + val in: Inlet[Any] = Inlet[Any]("Ignore.in")
  3711. + val shape: SinkShape[Any] = SinkShape(in)
  3712.  
  3713. - override def initialAttributes = DefaultAttributes.ignoreSink
  3714. + override def initialAttributes: Attributes = DefaultAttributes.ignoreSink
  3715.  
  3716. override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, Future[Done]) = {
  3717. val promise = Promise[Done]()
  3718. diff --git a/akka-stream/src/main/scala/akka/stream/impl/fusing/Ops.scala b/akka-stream/src/main/scala/akka/stream/impl/fusing/Ops.scala
  3719. index d11a2c4812..59717aca47 100644
  3720. --- a/akka-stream/src/main/scala/akka/stream/impl/fusing/Ops.scala
  3721. +++ b/akka-stream/src/main/scala/akka/stream/impl/fusing/Ops.scala
  3722. @@ -27,14 +27,15 @@ import akka.stream.ActorAttributes.SupervisionStrategy
  3723. import scala.concurrent.duration.{ FiniteDuration, _ }
  3724. import akka.stream.impl.Stages.DefaultAttributes
  3725. import akka.util.OptionVal
  3726. +import akka.stream.Supervision.Decider
  3727.  
  3728. /**
  3729. * INTERNAL API
  3730. */
  3731. @InternalApi private[akka] final case class Map[In, Out](f: In ⇒ Out) extends GraphStage[FlowShape[In, Out]] {
  3732. - val in = Inlet[In]("Map.in")
  3733. - val out = Outlet[Out]("Map.out")
  3734. - override val shape = FlowShape(in, out)
  3735. + val in: Inlet[In] = Inlet[In]("Map.in")
  3736. + val out: Outlet[Out] = Outlet[Out]("Map.out")
  3737. + override val shape: FlowShape[In, Out] = FlowShape(in, out)
  3738.  
  3739. override def initialAttributes: Attributes = DefaultAttributes.map
  3740.  
  3741. @@ -70,7 +71,7 @@ import akka.util.OptionVal
  3742.  
  3743. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  3744. new GraphStageLogic(shape) with OutHandler with InHandler {
  3745. - def decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3746. + def decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3747.  
  3748. override def onPush(): Unit = {
  3749. try {
  3750. @@ -106,7 +107,7 @@ import akka.util.OptionVal
  3751. new GraphStageLogic(shape) with OutHandler with InHandler {
  3752. override def toString = "TakeWhileLogic"
  3753.  
  3754. - def decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3755. + def decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3756.  
  3757. override def onPush(): Unit = {
  3758. try {
  3759. @@ -137,7 +138,7 @@ import akka.util.OptionVal
  3760. @InternalApi private[akka] final case class DropWhile[T](p: T ⇒ Boolean) extends SimpleLinearGraphStage[T] {
  3761. override def initialAttributes: Attributes = DefaultAttributes.dropWhile
  3762.  
  3763. - def createLogic(inheritedAttributes: Attributes) = new SupervisedGraphStageLogic(inheritedAttributes, shape) with InHandler with OutHandler {
  3764. + def createLogic(inheritedAttributes: Attributes): SupervisedGraphStageLogic with InHandler with OutHandler = new SupervisedGraphStageLogic(inheritedAttributes, shape) with InHandler with OutHandler {
  3765. override def onPush(): Unit = {
  3766. val elem = grab(in)
  3767. withSupervision(() ⇒ p(elem)) match {
  3768. @@ -149,8 +150,8 @@ import akka.util.OptionVal
  3769. }
  3770. }
  3771.  
  3772. - def rest = new InHandler {
  3773. - def onPush() = push(out, grab(in))
  3774. + def rest: InHandler = new InHandler {
  3775. + def onPush(): Unit = push(out, grab(in))
  3776. }
  3777.  
  3778. override def onResume(t: Throwable): Unit = if (!hasBeenPulled(in)) pull(in)
  3779. @@ -200,17 +201,17 @@ private[stream] object Collect {
  3780. * INTERNAL API
  3781. */
  3782. @InternalApi private[akka] final case class Collect[In, Out](pf: PartialFunction[In, Out]) extends GraphStage[FlowShape[In, Out]] {
  3783. - val in = Inlet[In]("Collect.in")
  3784. - val out = Outlet[Out]("Collect.out")
  3785. - override val shape = FlowShape(in, out)
  3786. + val in: Inlet[In] = Inlet[In]("Collect.in")
  3787. + val out: Outlet[Out] = Outlet[Out]("Collect.out")
  3788. + override val shape: FlowShape[In, Out] = FlowShape(in, out)
  3789.  
  3790. override def initialAttributes: Attributes = DefaultAttributes.collect
  3791.  
  3792. - def createLogic(inheritedAttributes: Attributes) = new SupervisedGraphStageLogic(inheritedAttributes, shape) with InHandler with OutHandler {
  3793. + def createLogic(inheritedAttributes: Attributes): SupervisedGraphStageLogic with InHandler with OutHandler = new SupervisedGraphStageLogic(inheritedAttributes, shape) with InHandler with OutHandler {
  3794.  
  3795. import Collect.NotApplied
  3796.  
  3797. - val wrappedPf = () ⇒ pf.applyOrElse(grab(in), NotApplied)
  3798. + val wrappedPf: () ⇒ Any = () ⇒ pf.applyOrElse(grab(in), NotApplied)
  3799.  
  3800. override def onPush(): Unit = withSupervision(wrappedPf) match {
  3801. case Some(result) ⇒ result match {
  3802. @@ -282,7 +283,7 @@ private[stream] object Collect {
  3803. * would log the `t2` error.
  3804. */
  3805. @InternalApi private[akka] final case class MapError[T](f: PartialFunction[Throwable, Throwable]) extends SimpleLinearGraphStage[T] {
  3806. - override def createLogic(attr: Attributes) =
  3807. + override def createLogic(attr: Attributes): GraphStageLogic with InHandler with OutHandler =
  3808. new GraphStageLogic(shape) with InHandler with OutHandler {
  3809. override def onPush(): Unit = push(out, grab(in))
  3810.  
  3811. @@ -352,7 +353,7 @@ private[stream] object Collect {
  3812. * INTERNAL API
  3813. */
  3814. @InternalApi private[akka] final case class Scan[In, Out](zero: Out, f: (Out, In) ⇒ Out) extends GraphStage[FlowShape[In, Out]] {
  3815. - override val shape = FlowShape[In, Out](Inlet("Scan.in"), Outlet("Scan.out"))
  3816. + override val shape: FlowShape[In, Out] = FlowShape[In, Out](Inlet("Scan.in"), Outlet("Scan.out"))
  3817.  
  3818. override def initialAttributes: Attributes = DefaultAttributes.scan
  3819.  
  3820. @@ -413,8 +414,8 @@ private[stream] object Collect {
  3821.  
  3822. import akka.dispatch.ExecutionContexts
  3823.  
  3824. - val in = Inlet[In]("ScanAsync.in")
  3825. - val out = Outlet[Out]("ScanAsync.out")
  3826. + val in: Inlet[In] = Inlet[In]("ScanAsync.in")
  3827. + val out: Outlet[Out] = Outlet[Out]("ScanAsync.out")
  3828. override val shape: FlowShape[In, Out] = FlowShape[In, Out](in, out)
  3829.  
  3830. override val initialAttributes: Attributes = Attributes.name("scanAsync")
  3831. @@ -529,13 +530,13 @@ private[stream] object Collect {
  3832. */
  3833. @InternalApi private[akka] final case class Fold[In, Out](zero: Out, f: (Out, In) ⇒ Out) extends GraphStage[FlowShape[In, Out]] {
  3834.  
  3835. - val in = Inlet[In]("Fold.in")
  3836. - val out = Outlet[Out]("Fold.out")
  3837. + val in: Inlet[In] = Inlet[In]("Fold.in")
  3838. + val out: Outlet[Out] = Outlet[Out]("Fold.out")
  3839. override val shape: FlowShape[In, Out] = FlowShape(in, out)
  3840.  
  3841. override def toString: String = "Fold"
  3842.  
  3843. - override val initialAttributes = DefaultAttributes.fold
  3844. + override val initialAttributes: Attributes = DefaultAttributes.fold
  3845.  
  3846. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  3847. new GraphStageLogic(shape) with InHandler with OutHandler {
  3848. @@ -586,17 +587,17 @@ private[stream] object Collect {
  3849.  
  3850. import akka.dispatch.ExecutionContexts
  3851.  
  3852. - val in = Inlet[In]("FoldAsync.in")
  3853. - val out = Outlet[Out]("FoldAsync.out")
  3854. - val shape = FlowShape.of(in, out)
  3855. + val in: Inlet[In] = Inlet[In]("FoldAsync.in")
  3856. + val out: Outlet[Out] = Outlet[Out]("FoldAsync.out")
  3857. + val shape: FlowShape[In, Out] = FlowShape.of(in, out)
  3858.  
  3859. override def toString: String = "FoldAsync"
  3860.  
  3861. - override val initialAttributes = DefaultAttributes.foldAsync
  3862. + override val initialAttributes: Attributes = DefaultAttributes.foldAsync
  3863.  
  3864. def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  3865. new GraphStageLogic(shape) with InHandler with OutHandler {
  3866. - val decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3867. + val decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3868.  
  3869. private var aggregator: Out = zero
  3870. private var aggregating: Future[Out] = Future.successful(aggregator)
  3871. @@ -669,7 +670,7 @@ private[stream] object Collect {
  3872.  
  3873. setHandlers(in, out, this)
  3874.  
  3875. - override def toString =
  3876. + override def toString: String =
  3877. s"FoldAsync.Logic(completed=${aggregating.isCompleted})"
  3878. }
  3879. }
  3880. @@ -683,7 +684,7 @@ private[stream] object Collect {
  3881. if (end.isDefined) ReactiveStreamsCompliance.requireNonNullElement(end.get)
  3882.  
  3883. override def createLogic(attr: Attributes): GraphStageLogic = new GraphStageLogic(shape) with OutHandler {
  3884. - val startInHandler = new InHandler {
  3885. + val startInHandler: InHandler = new InHandler {
  3886. override def onPush(): Unit = {
  3887. // if else (to avoid using Iterator[T].flatten in hot code)
  3888. if (start.isDefined) emitMultiple(out, Iterator(start.get, grab(in)))
  3889. @@ -697,7 +698,7 @@ private[stream] object Collect {
  3890. }
  3891. }
  3892.  
  3893. - val restInHandler = new InHandler {
  3894. + val restInHandler: InHandler = new InHandler {
  3895. override def onPush(): Unit = emitMultiple(out, Iterator(inject, grab(in)))
  3896.  
  3897. override def onUpstreamFinish(): Unit = {
  3898. @@ -719,8 +720,8 @@ private[stream] object Collect {
  3899. @InternalApi private[akka] final case class Grouped[T](n: Int) extends GraphStage[FlowShape[T, immutable.Seq[T]]] {
  3900. require(n > 0, "n must be greater than 0")
  3901.  
  3902. - val in = Inlet[T]("Grouped.in")
  3903. - val out = Outlet[immutable.Seq[T]]("Grouped.out")
  3904. + val in: Inlet[T] = Inlet[T]("Grouped.in")
  3905. + val out: Outlet[immutable.Seq[T]] = Outlet[immutable.Seq[T]]("Grouped.out")
  3906. override val shape: FlowShape[T, immutable.Seq[T]] = FlowShape(in, out)
  3907.  
  3908. override protected val initialAttributes: Attributes = DefaultAttributes.grouped
  3909. @@ -731,7 +732,7 @@ private[stream] object Collect {
  3910. b.sizeHint(n)
  3911. b
  3912. }
  3913. - var left = n
  3914. + var left: Int = n
  3915.  
  3916. override def onPush(): Unit = {
  3917. buf += grab(in)
  3918. @@ -773,7 +774,7 @@ private[stream] object Collect {
  3919. @InternalApi private[akka] final case class LimitWeighted[T](val n: Long, val costFn: T ⇒ Long) extends SimpleLinearGraphStage[T] {
  3920. override def initialAttributes: Attributes = DefaultAttributes.limitWeighted
  3921.  
  3922. - def createLogic(inheritedAttributes: Attributes) = new SupervisedGraphStageLogic(inheritedAttributes, shape) with InHandler with OutHandler {
  3923. + def createLogic(inheritedAttributes: Attributes): SupervisedGraphStageLogic with InHandler with OutHandler = new SupervisedGraphStageLogic(inheritedAttributes, shape) with InHandler with OutHandler {
  3924. private var left = n
  3925.  
  3926. override def onPush(): Unit = {
  3927. @@ -808,8 +809,8 @@ private[stream] object Collect {
  3928. require(n > 0, "n must be greater than 0")
  3929. require(step > 0, "step must be greater than 0")
  3930.  
  3931. - val in = Inlet[T]("Sliding.in")
  3932. - val out = Outlet[immutable.Seq[T]]("Sliding.out")
  3933. + val in: Inlet[T] = Inlet[T]("Sliding.in")
  3934. + val out: Outlet[immutable.Seq[T]] = Outlet[immutable.Seq[T]]("Sliding.out")
  3935. override val shape: FlowShape[T, immutable.Seq[T]] = FlowShape(in, out)
  3936.  
  3937. override protected val initialAttributes: Attributes = DefaultAttributes.sliding
  3938. @@ -938,14 +939,14 @@ private[stream] object Collect {
  3939. @InternalApi private[akka] final case class Batch[In, Out](val max: Long, val costFn: In ⇒ Long, val seed: In ⇒ Out, val aggregate: (Out, In) ⇒ Out)
  3940. extends GraphStage[FlowShape[In, Out]] {
  3941.  
  3942. - val in = Inlet[In]("Batch.in")
  3943. - val out = Outlet[Out]("Batch.out")
  3944. + val in: Inlet[In] = Inlet[In]("Batch.in")
  3945. + val out: Outlet[Out] = Outlet[Out]("Batch.out")
  3946.  
  3947. override val shape: FlowShape[In, Out] = FlowShape.of(in, out)
  3948.  
  3949. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with InHandler with OutHandler {
  3950.  
  3951. - lazy val decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3952. + lazy val decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  3953.  
  3954. private var agg: Out = null.asInstanceOf[Out]
  3955. private var left: Long = max
  3956. @@ -974,7 +975,7 @@ private[stream] object Collect {
  3957. }
  3958. }
  3959.  
  3960. - override def preStart() = pull(in)
  3961. + override def preStart(): Unit = pull(in)
  3962.  
  3963. def onPush(): Unit = {
  3964. val elem = grab(in)
  3965. @@ -1061,11 +1062,11 @@ private[stream] object Collect {
  3966. private val in = Inlet[In]("expand.in")
  3967. private val out = Outlet[Out]("expand.out")
  3968.  
  3969. - override def initialAttributes = DefaultAttributes.expand
  3970. + override def initialAttributes: Attributes = DefaultAttributes.expand
  3971.  
  3972. - override val shape = FlowShape(in, out)
  3973. + override val shape: FlowShape[In, Out] = FlowShape(in, out)
  3974.  
  3975. - override def createLogic(attr: Attributes) = new GraphStageLogic(shape) with InHandler with OutHandler {
  3976. + override def createLogic(attr: Attributes): GraphStageLogic with InHandler with OutHandler = new GraphStageLogic(shape) with InHandler with OutHandler {
  3977. private var iterator: Iterator[Out] = Iterator.empty
  3978. private var expanded = false
  3979.  
  3980. @@ -1145,7 +1146,7 @@ private[stream] object Collect {
  3981. }
  3982. }
  3983.  
  3984. - val NotYetThere = Failure(new Exception with NoStackTrace)
  3985. + val NotYetThere: Failure[Nothing] = Failure(new Exception with NoStackTrace)
  3986. }
  3987.  
  3988. /**
  3989. @@ -1159,14 +1160,14 @@ private[stream] object Collect {
  3990. private val in = Inlet[In]("MapAsync.in")
  3991. private val out = Outlet[Out]("MapAsync.out")
  3992.  
  3993. - override def initialAttributes = DefaultAttributes.mapAsync
  3994. + override def initialAttributes: Attributes = DefaultAttributes.mapAsync
  3995.  
  3996. - override val shape = FlowShape(in, out)
  3997. + override val shape: FlowShape[In, Out] = FlowShape(in, out)
  3998.  
  3999. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  4000. new GraphStageLogic(shape) with InHandler with OutHandler {
  4001.  
  4002. - lazy val decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  4003. + lazy val decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  4004. var buffer: BufferImpl[Holder[Out]] = _
  4005.  
  4006. private val futureCB = getAsyncCallback[Holder[Out]](holder ⇒
  4007. @@ -1255,15 +1256,15 @@ private[stream] object Collect {
  4008. private val in = Inlet[In]("MapAsyncUnordered.in")
  4009. private val out = Outlet[Out]("MapAsyncUnordered.out")
  4010.  
  4011. - override def initialAttributes = DefaultAttributes.mapAsyncUnordered
  4012. + override def initialAttributes: Attributes = DefaultAttributes.mapAsyncUnordered
  4013.  
  4014. - override val shape = FlowShape(in, out)
  4015. + override val shape: FlowShape[In, Out] = FlowShape(in, out)
  4016.  
  4017. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  4018. new GraphStageLogic(shape) with InHandler with OutHandler {
  4019. - override def toString = s"MapAsyncUnordered.Logic(inFlight=$inFlight, buffer=$buffer)"
  4020. + override def toString: String = s"MapAsyncUnordered.Logic(inFlight=$inFlight, buffer=$buffer)"
  4021.  
  4022. - val decider =
  4023. + val decider: Decider =
  4024. inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  4025.  
  4026. private var inFlight = 0
  4027. @@ -1343,7 +1344,7 @@ private[stream] object Collect {
  4028. private var logLevels: LogLevels = _
  4029. private var log: LoggingAdapter = _
  4030.  
  4031. - def decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  4032. + def decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  4033.  
  4034. override def preStart(): Unit = {
  4035. logLevels = inheritedAttributes.get[LogLevels](DefaultLogLevels)
  4036. @@ -1417,7 +1418,7 @@ private[stream] object Collect {
  4037. * Must be located here to be visible for implicit resolution, when [[Materializer]] is passed to [[Logging]]
  4038. * More specific LogSource than `fromString`, which would add the ActorSystem name in addition to the supervision to the log source.
  4039. */
  4040. - final val fromMaterializer = new LogSource[Materializer] {
  4041. + final val fromMaterializer: LogSource[Materializer] = new LogSource[Materializer] {
  4042.  
  4043. // do not expose private context classes (of OneBoundedInterpreter)
  4044. override def getClazz(t: Materializer): Class[_] = classOf[Materializer]
  4045. @@ -1459,12 +1460,12 @@ private[stream] object Collect {
  4046. require(maxWeight > 0, "maxWeight must be greater than 0")
  4047. require(interval > Duration.Zero)
  4048.  
  4049. - val in = Inlet[T]("in")
  4050. - val out = Outlet[immutable.Seq[T]]("out")
  4051. + val in: Inlet[T] = Inlet[T]("in")
  4052. + val out: Outlet[immutable.Seq[T]] = Outlet[immutable.Seq[T]]("out")
  4053.  
  4054. - override def initialAttributes = DefaultAttributes.groupedWeightedWithin
  4055. + override def initialAttributes: Attributes = DefaultAttributes.groupedWeightedWithin
  4056.  
  4057. - val shape = FlowShape(in, out)
  4058. + val shape: FlowShape[T, immutable.Seq[T]] = FlowShape(in, out)
  4059.  
  4060. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new TimerGraphStageLogic(shape) with InHandler with OutHandler {
  4061.  
  4062. @@ -1487,7 +1488,7 @@ private[stream] object Collect {
  4063. private var totalWeight = 0L
  4064. private var hasElements = false
  4065.  
  4066. - override def preStart() = {
  4067. + override def preStart(): Unit = {
  4068. schedulePeriodically(GroupedWeightedWithin.groupedWeightedWithinTimer, interval)
  4069. pull(in)
  4070. }
  4071. @@ -1575,7 +1576,7 @@ private[stream] object Collect {
  4072. else tryCloseGroup()
  4073. }
  4074.  
  4075. - override protected def onTimer(timerKey: Any) = if (hasElements) {
  4076. + override protected def onTimer(timerKey: Any): Unit = if (hasElements) {
  4077. if (isAvailable(out)) emitGroup()
  4078. else pushEagerly = true
  4079. }
  4080. @@ -1594,9 +1595,9 @@ private[stream] object Collect {
  4081. override def initialAttributes: Attributes = DefaultAttributes.delay
  4082.  
  4083. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new TimerGraphStageLogic(shape) with InHandler with OutHandler {
  4084. - val size = inheritedAttributes.mandatoryAttribute[InputBuffer].max
  4085. + val size: Int = inheritedAttributes.mandatoryAttribute[InputBuffer].max
  4086.  
  4087. - val delayMillis = d.toMillis
  4088. + val delayMillis: Long = d.toMillis
  4089.  
  4090. var buffer: BufferImpl[(Long, T)] = _ // buffer has pairs timestamp with upstream element
  4091.  
  4092. @@ -1741,7 +1742,7 @@ private[stream] object Collect {
  4093. push(out, grab(in))
  4094. // change the in handler to avoid System.nanoTime call after timeout
  4095. setHandler(in, new InHandler {
  4096. - def onPush() = push(out, grab(in))
  4097. + def onPush(): Unit = push(out, grab(in))
  4098. })
  4099. }
  4100. }
  4101. @@ -1763,7 +1764,7 @@ private[stream] object Collect {
  4102.  
  4103. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with InHandler with OutHandler {
  4104. self ⇒
  4105. - override def toString = s"Reduce.Logic(aggregator=$aggregator)"
  4106. + override def toString: String = s"Reduce.Logic(aggregator=$aggregator)"
  4107.  
  4108. var aggregator: T = _
  4109.  
  4110. @@ -1823,22 +1824,22 @@ private[stream] object Collect {
  4111.  
  4112. @InternalApi private[akka] final class RecoverWith[T, M](val maximumRetries: Int, val pf: PartialFunction[Throwable, Graph[SourceShape[T], M]]) extends SimpleLinearGraphStage[T] {
  4113.  
  4114. - override def initialAttributes = DefaultAttributes.recoverWith
  4115. + override def initialAttributes: Attributes = DefaultAttributes.recoverWith
  4116.  
  4117. - override def createLogic(attr: Attributes) = new GraphStageLogic(shape) {
  4118. + override def createLogic(attr: Attributes): GraphStageLogic = new GraphStageLogic(shape) {
  4119. var attempt = 0
  4120.  
  4121. setHandler(in, new InHandler {
  4122. override def onPush(): Unit = push(out, grab(in))
  4123.  
  4124. - override def onUpstreamFailure(ex: Throwable) = onFailure(ex)
  4125. + override def onUpstreamFailure(ex: Throwable): Unit = onFailure(ex)
  4126. })
  4127.  
  4128. setHandler(out, new OutHandler {
  4129. override def onPull(): Unit = pull(in)
  4130. })
  4131.  
  4132. - def onFailure(ex: Throwable) =
  4133. + def onFailure(ex: Throwable): Unit =
  4134. if ((maximumRetries < 0 || attempt < maximumRetries) && pf.isDefinedAt(ex)) {
  4135. switchTo(pf(ex))
  4136. attempt += 1
  4137. @@ -1853,7 +1854,7 @@ private[stream] object Collect {
  4138.  
  4139. override def onUpstreamFinish(): Unit = completeStage()
  4140.  
  4141. - override def onUpstreamFailure(ex: Throwable) = onFailure(ex)
  4142. + override def onUpstreamFailure(ex: Throwable): Unit = onFailure(ex)
  4143. })
  4144.  
  4145. val outHandler = new OutHandler {
  4146. @@ -1875,18 +1876,18 @@ private[stream] object Collect {
  4147. * INTERNAL API
  4148. */
  4149. @InternalApi private[akka] final class StatefulMapConcat[In, Out](val f: () ⇒ In ⇒ immutable.Iterable[Out]) extends GraphStage[FlowShape[In, Out]] {
  4150. - val in = Inlet[In]("StatefulMapConcat.in")
  4151. - val out = Outlet[Out]("StatefulMapConcat.out")
  4152. - override val shape = FlowShape(in, out)
  4153. + val in: Inlet[In] = Inlet[In]("StatefulMapConcat.in")
  4154. + val out: Outlet[Out] = Outlet[Out]("StatefulMapConcat.out")
  4155. + override val shape: FlowShape[In, Out] = FlowShape(in, out)
  4156.  
  4157. override def initialAttributes: Attributes = DefaultAttributes.statefulMapConcat
  4158.  
  4159. - def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) with InHandler with OutHandler {
  4160. - lazy val decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  4161. + def createLogic(inheritedAttributes: Attributes): GraphStageLogic with InHandler with OutHandler = new GraphStageLogic(shape) with InHandler with OutHandler {
  4162. + lazy val decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  4163. var currentIterator: Iterator[Out] = _
  4164. - var plainFun = f()
  4165. + var plainFun: In ⇒ immutable.Iterable[Out] = f()
  4166.  
  4167. - def hasNext = if (currentIterator != null) currentIterator.hasNext else false
  4168. + def hasNext: Boolean = if (currentIterator != null) currentIterator.hasNext else false
  4169.  
  4170. setHandlers(in, out, this)
  4171.  
  4172. diff --git a/akka-stream/src/main/scala/akka/stream/impl/fusing/StreamOfStreams.scala b/akka-stream/src/main/scala/akka/stream/impl/fusing/StreamOfStreams.scala
  4173. index 23e7a5d47e..8caf640e72 100644
  4174. --- a/akka-stream/src/main/scala/akka/stream/impl/fusing/StreamOfStreams.scala
  4175. +++ b/akka-stream/src/main/scala/akka/stream/impl/fusing/StreamOfStreams.scala
  4176. @@ -24,6 +24,7 @@ import akka.stream.impl.CancellingSubscriber
  4177. import akka.stream.impl.{ Buffer ⇒ BufferImpl }
  4178.  
  4179. import scala.collection.JavaConverters._
  4180. +import akka.stream.Supervision.Decider
  4181.  
  4182. /**
  4183. * INTERNAL API
  4184. @@ -32,12 +33,12 @@ import scala.collection.JavaConverters._
  4185. private val in = Inlet[Graph[SourceShape[T], M]]("flatten.in")
  4186. private val out = Outlet[T]("flatten.out")
  4187.  
  4188. - override def initialAttributes = DefaultAttributes.flattenMerge
  4189. - override val shape = FlowShape(in, out)
  4190. + override def initialAttributes: Attributes = DefaultAttributes.flattenMerge
  4191. + override val shape: FlowShape[Graph[SourceShape[T], M], T] = FlowShape(in, out)
  4192.  
  4193. - override def createLogic(enclosingAttributes: Attributes) = new GraphStageLogic(shape) {
  4194. + override def createLogic(enclosingAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) {
  4195. var sources = Set.empty[SubSinkInlet[T]]
  4196. - def activeSources = sources.size
  4197. + def activeSources: Int = sources.size
  4198.  
  4199. var q: BufferImpl[SubSinkInlet[T]] = _
  4200.  
  4201. @@ -66,7 +67,7 @@ import scala.collection.JavaConverters._
  4202. }
  4203. })
  4204.  
  4205. - val outHandler = new OutHandler {
  4206. + val outHandler: OutHandler = new OutHandler {
  4207. // could be unavailable due to async input having been executed before this notification
  4208. override def onPull(): Unit = if (q.nonEmpty && isAvailable(out)) pushOut()
  4209. }
  4210. @@ -112,7 +113,7 @@ import scala.collection.JavaConverters._
  4211. val out: Outlet[(immutable.Seq[T], Source[T, NotUsed])] = Outlet("PrefixAndTail.out")
  4212. override val shape: FlowShape[T, (immutable.Seq[T], Source[T, NotUsed])] = FlowShape(in, out)
  4213.  
  4214. - override def initialAttributes = DefaultAttributes.prefixAndTail
  4215. + override def initialAttributes: Attributes = DefaultAttributes.prefixAndTail
  4216.  
  4217. private final class PrefixAndTailLogic(_shape: Shape) extends TimerGraphStageLogic(_shape) with OutHandler with InHandler {
  4218.  
  4219. @@ -219,11 +220,11 @@ import scala.collection.JavaConverters._
  4220. val in: Inlet[T] = Inlet("GroupBy.in")
  4221. val out: Outlet[Source[T, NotUsed]] = Outlet("GroupBy.out")
  4222. override val shape: FlowShape[T, Source[T, NotUsed]] = FlowShape(in, out)
  4223. - override def initialAttributes = DefaultAttributes.groupBy
  4224. + override def initialAttributes: Attributes = DefaultAttributes.groupBy
  4225.  
  4226. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new TimerGraphStageLogic(shape) with OutHandler with InHandler {
  4227. parent ⇒
  4228. - lazy val decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  4229. + lazy val decider: Decider = inheritedAttributes.mandatoryAttribute[SupervisionStrategy].decider
  4230. private val activeSubstreamsMap = new java.util.HashMap[Any, SubstreamSource]()
  4231. private val closedSubstreams = new java.util.HashSet[Any]()
  4232. private var timeout: FiniteDuration = _
  4233. @@ -341,7 +342,7 @@ import scala.collection.JavaConverters._
  4234.  
  4235. private class SubstreamSource(name: String, val key: K, var firstElement: T) extends SubSourceOutlet[T](name) with OutHandler {
  4236. def firstPush(): Boolean = firstElement != null
  4237. - def hasNextForSubSource = hasNextElement && nextElementKey == key
  4238. + def hasNextForSubSource: Boolean = hasNextElement && nextElementKey == key
  4239. private def completeSubStream(): Unit = {
  4240. complete()
  4241. activeSubstreamsMap.remove(key)
  4242. @@ -445,7 +446,7 @@ import scala.collection.JavaConverters._
  4243. }
  4244. })
  4245.  
  4246. - val initInHandler = new InHandler {
  4247. + val initInHandler: InHandler = new InHandler {
  4248. override def onPush(): Unit = {
  4249. val handler = new SubstreamHandler
  4250. val elem = grab(in)
  4251. @@ -608,8 +609,8 @@ import scala.collection.JavaConverters._
  4252.  
  4253. private val in = Inlet[T](s"SubSink($name).in")
  4254.  
  4255. - override def initialAttributes = Attributes.name(s"SubSink($name)")
  4256. - override val shape = SinkShape(in)
  4257. + override def initialAttributes: Attributes = Attributes.name(s"SubSink($name)")
  4258. + override val shape: SinkShape[T] = SinkShape(in)
  4259.  
  4260. private val status = new AtomicReference[ /* State */ AnyRef](Uninitialized)
  4261.  
  4262. @@ -633,7 +634,7 @@ import scala.collection.JavaConverters._
  4263. throw new IllegalStateException(s"${newState.command} on subsink is illegal when ${cmd.command} is still pending")
  4264. }
  4265.  
  4266. - override def createLogic(attr: Attributes) = new GraphStageLogic(shape) with InHandler {
  4267. + override def createLogic(attr: Attributes): GraphStageLogic with InHandler = new GraphStageLogic(shape) with InHandler {
  4268. setHandler(in, this)
  4269.  
  4270. override def onPush(): Unit = externalCallback(ActorSubscriberMessage.OnNext(grab(in)))
  4271. @@ -677,7 +678,7 @@ import scala.collection.JavaConverters._
  4272. import SubSink._
  4273.  
  4274. val out: Outlet[T] = Outlet(s"SubSource($name).out")
  4275. - override def initialAttributes = Attributes.name(s"SubSource($name)")
  4276. + override def initialAttributes: Attributes = Attributes.name(s"SubSource($name)")
  4277. override val shape: SourceShape[T] = SourceShape(out)
  4278.  
  4279. private val status = new AtomicReference[AnyRef]
  4280. @@ -705,7 +706,7 @@ import scala.collection.JavaConverters._
  4281. def timeout(d: FiniteDuration): Boolean =
  4282. status.compareAndSet(null, ActorSubscriberMessage.OnError(new SubscriptionTimeoutException(s"Substream Source has not been materialized in $d")))
  4283.  
  4284. - override def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) with OutHandler {
  4285. + override def createLogic(inheritedAttributes: Attributes): GraphStageLogic with OutHandler = new GraphStageLogic(shape) with OutHandler {
  4286. setHandler(out, this)
  4287.  
  4288. @tailrec private def setCB(cb: AsyncCallback[ActorSubscriberMessage]): Unit = {
  4289. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/ByteStringParser.scala b/akka-stream/src/main/scala/akka/stream/impl/io/ByteStringParser.scala
  4290. index d8c843ec99..edc461013e 100644
  4291. --- a/akka-stream/src/main/scala/akka/stream/impl/io/ByteStringParser.scala
  4292. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/ByteStringParser.scala
  4293. @@ -20,8 +20,8 @@ import scala.util.control.{ NoStackTrace, NonFatal }
  4294. private val bytesIn = Inlet[ByteString]("bytesIn")
  4295. private val objOut = Outlet[T]("objOut")
  4296.  
  4297. - override def initialAttributes = Attributes.name("ByteStringParser")
  4298. - final override val shape = FlowShape(bytesIn, objOut)
  4299. + override def initialAttributes: Attributes = Attributes.name("ByteStringParser")
  4300. + final override val shape: FlowShape[ByteString, T] = FlowShape(bytesIn, objOut)
  4301.  
  4302. class ParsingLogic extends GraphStageLogic(shape) with InHandler with OutHandler {
  4303. private var buffer = ByteString.empty
  4304. @@ -174,13 +174,13 @@ import scala.util.control.{ NoStackTrace, NonFatal }
  4305. }
  4306.  
  4307. object FinishedParser extends ParseStep[Nothing] {
  4308. - override def parse(reader: ByteReader) =
  4309. + override def parse(reader: ByteReader): Nothing =
  4310. throw new IllegalStateException("no initial parser installed: you must use startWith(...)")
  4311. }
  4312.  
  4313. class ParsingException(msg: String, cause: Throwable) extends RuntimeException(msg, cause)
  4314.  
  4315. - val NeedMoreData = new Exception with NoStackTrace
  4316. + val NeedMoreData: Exception with NoStackTrace = new Exception with NoStackTrace
  4317.  
  4318. class ByteReader(input: ByteString) {
  4319.  
  4320. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/FileSubscriber.scala b/akka-stream/src/main/scala/akka/stream/impl/io/FileSubscriber.scala
  4321. index 2ef4f34dd2..a89e546e6e 100644
  4322. --- a/akka-stream/src/main/scala/akka/stream/impl/io/FileSubscriber.scala
  4323. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/FileSubscriber.scala
  4324. @@ -19,7 +19,7 @@ import scala.util.{ Failure, Success }
  4325.  
  4326. /** INTERNAL API */
  4327. @InternalApi private[akka] object FileSubscriber {
  4328. - def props(f: Path, completionPromise: Promise[IOResult], bufSize: Int, startPosition: Long, openOptions: Set[OpenOption]) = {
  4329. + def props(f: Path, completionPromise: Promise[IOResult], bufSize: Int, startPosition: Long, openOptions: Set[OpenOption]): Props = {
  4330. require(bufSize > 0, "buffer size must be > 0")
  4331. require(startPosition >= 0, s"startPosition must be >= 0 (was $startPosition)")
  4332. Props(classOf[FileSubscriber], f, completionPromise, bufSize, startPosition, openOptions).withDeploy(Deploy.local)
  4333. @@ -31,7 +31,7 @@ import scala.util.{ Failure, Success }
  4334. extends akka.stream.actor.ActorSubscriber
  4335. with ActorLogging {
  4336.  
  4337. - override protected val requestStrategy = WatermarkRequestStrategy(highWatermark = bufSize)
  4338. + override protected val requestStrategy: WatermarkRequestStrategy = WatermarkRequestStrategy(highWatermark = bufSize)
  4339.  
  4340. private var chan: FileChannel = _
  4341.  
  4342. @@ -50,7 +50,7 @@ import scala.util.{ Failure, Success }
  4343. cancel()
  4344. }
  4345.  
  4346. - def receive = {
  4347. + def receive: PartialFunction[Any, Unit] = {
  4348. case ActorSubscriberMessage.OnNext(bytes: ByteString) ⇒
  4349. try {
  4350. bytesWritten += chan.write(bytes.asByteBuffer)
  4351. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/IOSinks.scala b/akka-stream/src/main/scala/akka/stream/impl/io/IOSinks.scala
  4352. index 4eb5d366fe..d54e565277 100644
  4353. --- a/akka-stream/src/main/scala/akka/stream/impl/io/IOSinks.scala
  4354. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/IOSinks.scala
  4355. @@ -15,6 +15,7 @@ import akka.util.ByteString
  4356.  
  4357. import scala.collection.immutable
  4358. import scala.concurrent.{ Future, Promise }
  4359. +import org.reactivestreams.Subscriber
  4360.  
  4361. /**
  4362. * INTERNAL API
  4363. @@ -26,7 +27,7 @@ import scala.concurrent.{ Future, Promise }
  4364.  
  4365. override protected def label: String = s"FileSink($f, $options)"
  4366.  
  4367. - override def create(context: MaterializationContext) = {
  4368. + override def create(context: MaterializationContext): (Subscriber[ByteString], Future[IOResult]) = {
  4369. val materializer = ActorMaterializerHelper.downcast(context.materializer)
  4370.  
  4371. val maxInputBufferSize = context.effectiveAttributes.mandatoryAttribute[Attributes.InputBuffer].max
  4372. @@ -53,7 +54,7 @@ import scala.concurrent.{ Future, Promise }
  4373. @InternalApi private[akka] final class OutputStreamSink(createOutput: () ⇒ OutputStream, val attributes: Attributes, shape: SinkShape[ByteString], autoFlush: Boolean)
  4374. extends SinkModule[ByteString, Future[IOResult]](shape) {
  4375.  
  4376. - override def create(context: MaterializationContext) = {
  4377. + override def create(context: MaterializationContext): (Subscriber[ByteString], Future[IOResult]) = {
  4378. val materializer = ActorMaterializerHelper.downcast(context.materializer)
  4379. val ioResultPromise = Promise[IOResult]()
  4380.  
  4381. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/IOSources.scala b/akka-stream/src/main/scala/akka/stream/impl/io/IOSources.scala
  4382. index 90958ae5d2..ed9994b024 100644
  4383. --- a/akka-stream/src/main/scala/akka/stream/impl/io/IOSources.scala
  4384. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/IOSources.scala
  4385. @@ -29,7 +29,7 @@ import scala.util.{ Failure, Success, Try }
  4386.  
  4387. private[akka] object FileSource {
  4388.  
  4389. - val completionHandler = new CompletionHandler[Integer, Try[Int] ⇒ Unit] {
  4390. + val completionHandler: Object with CompletionHandler[Integer, Try[Int] ⇒ Unit] = new CompletionHandler[Integer, Try[Int] ⇒ Unit] {
  4391.  
  4392. override def completed(result: Integer, attachment: Try[Int] ⇒ Unit): Unit = {
  4393. attachment(Success(result))
  4394. @@ -48,19 +48,19 @@ private[akka] object FileSource {
  4395. private[akka] final class FileSource(path: Path, chunkSize: Int, startPosition: Long)
  4396. extends GraphStageWithMaterializedValue[SourceShape[ByteString], Future[IOResult]] {
  4397. require(chunkSize > 0, "chunkSize must be greater than 0")
  4398. - val out = Outlet[ByteString]("FileSource.out")
  4399. + val out: Outlet[ByteString] = Outlet[ByteString]("FileSource.out")
  4400.  
  4401. - override val shape = SourceShape(out)
  4402. + override val shape: SourceShape[ByteString] = SourceShape(out)
  4403.  
  4404. override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, Future[IOResult]) = {
  4405. val ioResultPromise = Promise[IOResult]()
  4406.  
  4407. val logic = new GraphStageLogic(shape) with OutHandler {
  4408. handler ⇒
  4409. - val buffer = ByteBuffer.allocate(chunkSize)
  4410. - val maxReadAhead = inheritedAttributes.getAttribute(classOf[InputBuffer], InputBuffer(16, 16)).max
  4411. + val buffer: ByteBuffer = ByteBuffer.allocate(chunkSize)
  4412. + val maxReadAhead: Int = inheritedAttributes.getAttribute(classOf[InputBuffer], InputBuffer(16, 16)).max
  4413. var channel: FileChannel = _
  4414. - var position = startPosition
  4415. + var position: Long = startPosition
  4416. var chunkCallback: Try[Int] ⇒ Unit = _
  4417. var eofEncountered = false
  4418. var availableChunks: Vector[ByteString] = Vector.empty[ByteString]
  4419. @@ -137,7 +137,7 @@ private[akka] final class FileSource(path: Path, chunkSize: Int, startPosition:
  4420. (logic, ioResultPromise.future)
  4421. }
  4422.  
  4423. - override def toString = s"FileSource($path, $chunkSize)"
  4424. + override def toString: String = s"FileSource($path, $chunkSize)"
  4425. }
  4426.  
  4427. /**
  4428. @@ -146,7 +146,7 @@ private[akka] final class FileSource(path: Path, chunkSize: Int, startPosition:
  4429. */
  4430. @InternalApi private[akka] final class InputStreamSource(createInputStream: () ⇒ InputStream, chunkSize: Int, val attributes: Attributes, shape: SourceShape[ByteString])
  4431. extends SourceModule[ByteString, Future[IOResult]](shape) {
  4432. - override def create(context: MaterializationContext) = {
  4433. + override def create(context: MaterializationContext): (Publisher[ByteString], Future[IOResult]) = {
  4434. val materializer = ActorMaterializerHelper.downcast(context.materializer)
  4435. val ioResultPromise = Promise[IOResult]()
  4436.  
  4437. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/InputStreamPublisher.scala b/akka-stream/src/main/scala/akka/stream/impl/io/InputStreamPublisher.scala
  4438. index bf4e55da97..18da203600 100644
  4439. --- a/akka-stream/src/main/scala/akka/stream/impl/io/InputStreamPublisher.scala
  4440. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/InputStreamPublisher.scala
  4441. @@ -36,10 +36,10 @@ import scala.util.{ Failure, Success }
  4442.  
  4443. import InputStreamPublisher._
  4444.  
  4445. - val arr = new Array[Byte](chunkSize)
  4446. + val arr: Array[Byte] = new Array[Byte](chunkSize)
  4447. var readBytesTotal = 0L
  4448.  
  4449. - def receive = {
  4450. + def receive: PartialFunction[Any, Unit] = {
  4451. case ActorPublisherMessage.Request(elements) ⇒ readAndSignal()
  4452. case Continue ⇒ readAndSignal()
  4453. case ActorPublisherMessage.Cancel ⇒ context.stop(self)
  4454. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/InputStreamSinkStage.scala b/akka-stream/src/main/scala/akka/stream/impl/io/InputStreamSinkStage.scala
  4455. index c4c637e42c..3cea90d3e3 100644
  4456. --- a/akka-stream/src/main/scala/akka/stream/impl/io/InputStreamSinkStage.scala
  4457. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/InputStreamSinkStage.scala
  4458. @@ -39,7 +39,7 @@ private[stream] object InputStreamSinkStage {
  4459. */
  4460. @InternalApi final private[stream] class InputStreamSinkStage(readTimeout: FiniteDuration) extends GraphStageWithMaterializedValue[SinkShape[ByteString], InputStream] {
  4461.  
  4462. - val in = Inlet[ByteString]("InputStreamSink.in")
  4463. + val in: Inlet[ByteString] = Inlet[ByteString]("InputStreamSink.in")
  4464. override def initialAttributes: Attributes = DefaultAttributes.inputStreamSink
  4465. override val shape: SinkShape[ByteString] = SinkShape.of(in)
  4466.  
  4467. @@ -65,7 +65,7 @@ private[stream] object InputStreamSinkStage {
  4468. if (dataQueue.remainingCapacity() > 1 && !hasBeenPulled(in))
  4469. pull(in)
  4470.  
  4471. - override def preStart() = {
  4472. + override def preStart(): Unit = {
  4473. dataQueue.add(Initialized)
  4474. pull(in)
  4475. }
  4476. @@ -114,7 +114,7 @@ private[stream] object InputStreamSinkStage {
  4477. var isInitialized = false
  4478. var isActive = true
  4479. var isStageAlive = true
  4480. - def subscriberClosedException = new IOException("Reactive stream is terminated, no reads are possible")
  4481. + def subscriberClosedException: IOException = new IOException("Reactive stream is terminated, no reads are possible")
  4482. var detachedChunk: Option[ByteString] = None
  4483.  
  4484. @scala.throws(classOf[IOException])
  4485. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/OutputStreamSourceStage.scala b/akka-stream/src/main/scala/akka/stream/impl/io/OutputStreamSourceStage.scala
  4486. index 65b71c2a4b..d53ec459a0 100644
  4487. --- a/akka-stream/src/main/scala/akka/stream/impl/io/OutputStreamSourceStage.scala
  4488. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/OutputStreamSourceStage.scala
  4489. @@ -35,8 +35,8 @@ private[stream] object OutputStreamSourceStage {
  4490. }
  4491.  
  4492. final private[stream] class OutputStreamSourceStage(writeTimeout: FiniteDuration) extends GraphStageWithMaterializedValue[SourceShape[ByteString], OutputStream] {
  4493. - val out = Outlet[ByteString]("OutputStreamSource.out")
  4494. - override def initialAttributes = DefaultAttributes.outputStreamSource
  4495. + val out: Outlet[ByteString] = Outlet[ByteString]("OutputStreamSource.out")
  4496. + override def initialAttributes: Attributes = DefaultAttributes.outputStreamSource
  4497. override val shape: SourceShape[ByteString] = SourceShape.of(out)
  4498.  
  4499. override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, OutputStream) = {
  4500. @@ -159,7 +159,7 @@ private[akka] class OutputStreamAdapter(
  4501.  
  4502. var isActive = true
  4503. var isPublisherAlive = true
  4504. - def publisherClosedException = new IOException("Reactive stream is terminated, no writes are possible")
  4505. + def publisherClosedException: IOException = new IOException("Reactive stream is terminated, no writes are possible")
  4506.  
  4507. @scala.throws(classOf[IOException])
  4508. private[this] def send(sendAction: () ⇒ Unit): Unit = {
  4509. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/OutputStreamSubscriber.scala b/akka-stream/src/main/scala/akka/stream/impl/io/OutputStreamSubscriber.scala
  4510. index 3943aa963d..4a8d5cb79b 100644
  4511. --- a/akka-stream/src/main/scala/akka/stream/impl/io/OutputStreamSubscriber.scala
  4512. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/OutputStreamSubscriber.scala
  4513. @@ -17,7 +17,7 @@ import scala.util.{ Failure, Success }
  4514.  
  4515. /** INTERNAL API */
  4516. @InternalApi private[akka] object OutputStreamSubscriber {
  4517. - def props(os: OutputStream, completionPromise: Promise[IOResult], bufSize: Int, autoFlush: Boolean) = {
  4518. + def props(os: OutputStream, completionPromise: Promise[IOResult], bufSize: Int, autoFlush: Boolean): Props = {
  4519. require(bufSize > 0, "buffer size must be > 0")
  4520. Props(classOf[OutputStreamSubscriber], os, completionPromise, bufSize, autoFlush).withDeploy(Deploy.local)
  4521. }
  4522. @@ -29,11 +29,11 @@ import scala.util.{ Failure, Success }
  4523. extends akka.stream.actor.ActorSubscriber
  4524. with ActorLogging {
  4525.  
  4526. - override protected val requestStrategy = WatermarkRequestStrategy(highWatermark = bufSize)
  4527. + override protected val requestStrategy: WatermarkRequestStrategy = WatermarkRequestStrategy(highWatermark = bufSize)
  4528.  
  4529. private var bytesWritten: Long = 0
  4530.  
  4531. - def receive = {
  4532. + def receive: PartialFunction[Any, Unit] = {
  4533. case ActorSubscriberMessage.OnNext(bytes: ByteString) ⇒
  4534. try {
  4535. // blocking write
  4536. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/TLSActor.scala b/akka-stream/src/main/scala/akka/stream/impl/io/TLSActor.scala
  4537. index 4ceac8c983..53c8060477 100644
  4538. --- a/akka-stream/src/main/scala/akka/stream/impl/io/TLSActor.scala
  4539. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/TLSActor.scala
  4540. @@ -56,10 +56,10 @@ import scala.util.{ Failure, Success, Try }
  4541.  
  4542. import TLSActor._
  4543.  
  4544. - protected val outputBunch = new OutputBunch(outputCount = 2, self, this)
  4545. + protected val outputBunch: OutputBunch = new OutputBunch(outputCount = 2, self, this)
  4546. outputBunch.markAllOutputs()
  4547.  
  4548. - protected val inputBunch = new InputBunch(inputCount = 2, maxInputBufferSize, this) {
  4549. + protected val inputBunch: InputBunch = new InputBunch(inputCount = 2, maxInputBufferSize, this) {
  4550. override def onError(input: Int, e: Throwable): Unit = fail(e)
  4551. }
  4552.  
  4553. @@ -152,13 +152,13 @@ import scala.util.{ Failure, Success, Try }
  4554.  
  4555. // The engine could also be instantiated in ActorMaterializerImpl but if creation fails
  4556. // during materialization it would be worse than failing later on.
  4557. - val engine =
  4558. + val engine: SSLEngine =
  4559. try createSSLEngine(context.system) catch { case NonFatal(ex) ⇒ fail(ex, closeTransport = true); throw ex }
  4560.  
  4561. engine.beginHandshake()
  4562. lastHandshakeStatus = engine.getHandshakeStatus
  4563.  
  4564. - var currentSession = engine.getSession
  4565. + var currentSession: SSLSession = engine.getSession
  4566.  
  4567. def setNewSessionParameters(params: NegotiateNewSession): Unit = {
  4568. if (tracing) log.debug(s"applying $params")
  4569. @@ -193,35 +193,35 @@ import scala.util.{ Failure, Success, Try }
  4570. * representing the Engine.
  4571. */
  4572.  
  4573. - val engineNeedsWrap = new TransferState {
  4574. - def isReady = lastHandshakeStatus == NEED_WRAP
  4575. - def isCompleted = engine.isOutboundDone
  4576. + val engineNeedsWrap: TransferState = new TransferState {
  4577. + def isReady: Boolean = lastHandshakeStatus == NEED_WRAP
  4578. + def isCompleted: Boolean = engine.isOutboundDone
  4579. }
  4580.  
  4581. - val engineInboundOpen = new TransferState {
  4582. + val engineInboundOpen: TransferState = new TransferState {
  4583. def isReady = true
  4584. - def isCompleted = engine.isInboundDone
  4585. + def isCompleted: Boolean = engine.isInboundDone
  4586. }
  4587.  
  4588. - val userHasData = new TransferState {
  4589. - def isReady = !corkUser && userInChoppingBlock.isReady && lastHandshakeStatus != NEED_UNWRAP
  4590. - def isCompleted = inputBunch.isCancelled(UserIn) || inputBunch.isDepleted(UserIn)
  4591. + val userHasData: TransferState = new TransferState {
  4592. + def isReady: Boolean = !corkUser && userInChoppingBlock.isReady && lastHandshakeStatus != NEED_UNWRAP
  4593. + def isCompleted: Boolean = inputBunch.isCancelled(UserIn) || inputBunch.isDepleted(UserIn)
  4594. }
  4595.  
  4596. - val userOutCancelled = new TransferState {
  4597. - def isReady = outputBunch.isCancelled(UserOut)
  4598. - def isCompleted = engine.isInboundDone || outputBunch.isErrored(UserOut)
  4599. + val userOutCancelled: TransferState = new TransferState {
  4600. + def isReady: Boolean = outputBunch.isCancelled(UserOut)
  4601. + def isCompleted: Boolean = engine.isInboundDone || outputBunch.isErrored(UserOut)
  4602. }
  4603.  
  4604. // bidirectional case
  4605. - val outbound = (userHasData || engineNeedsWrap) && outputBunch.demandAvailableFor(TransportOut)
  4606. - val inbound = (transportInChoppingBlock && outputBunch.demandAvailableFor(UserOut)) || userOutCancelled
  4607. + val outbound: TransferState = (userHasData || engineNeedsWrap) && outputBunch.demandAvailableFor(TransportOut)
  4608. + val inbound: TransferState = (transportInChoppingBlock && outputBunch.demandAvailableFor(UserOut)) || userOutCancelled
  4609.  
  4610. // half-closed
  4611. - val outboundHalfClosed = engineNeedsWrap && outputBunch.demandAvailableFor(TransportOut)
  4612. - val inboundHalfClosed = transportInChoppingBlock && engineInboundOpen
  4613. + val outboundHalfClosed: TransferState = engineNeedsWrap && outputBunch.demandAvailableFor(TransportOut)
  4614. + val inboundHalfClosed: TransferState = transportInChoppingBlock && engineInboundOpen
  4615.  
  4616. - val bidirectional = TransferPhase(outbound || inbound) { () ⇒
  4617. + val bidirectional: TransferPhase = TransferPhase(outbound || inbound) { () ⇒
  4618. if (tracing) log.debug("bidirectional")
  4619. val continue = doInbound(isOutboundClosed = false, inbound)
  4620. if (continue) {
  4621. @@ -230,20 +230,20 @@ import scala.util.{ Failure, Success, Try }
  4622. }
  4623. }
  4624.  
  4625. - val flushingOutbound = TransferPhase(outboundHalfClosed) { () ⇒
  4626. + val flushingOutbound: TransferPhase = TransferPhase(outboundHalfClosed) { () ⇒
  4627. if (tracing) log.debug("flushingOutbound")
  4628. try doWrap()
  4629. catch { case ex: SSLException ⇒ nextPhase(completedPhase) }
  4630. }
  4631.  
  4632. - val awaitingClose = TransferPhase(inputBunch.inputsAvailableFor(TransportIn) && engineInboundOpen) { () ⇒
  4633. + val awaitingClose: TransferPhase = TransferPhase(inputBunch.inputsAvailableFor(TransportIn) && engineInboundOpen) { () ⇒
  4634. if (tracing) log.debug("awaitingClose")
  4635. transportInChoppingBlock.chopInto(transportInBuffer)
  4636. try doUnwrap(ignoreOutput = true)
  4637. catch { case ex: SSLException ⇒ nextPhase(completedPhase) }
  4638. }
  4639.  
  4640. - val outboundClosed = TransferPhase(outboundHalfClosed || inbound) { () ⇒
  4641. + val outboundClosed: TransferPhase = TransferPhase(outboundHalfClosed || inbound) { () ⇒
  4642. if (tracing) log.debug("outboundClosed")
  4643. val continue = doInbound(isOutboundClosed = true, inbound)
  4644. if (continue && outboundHalfClosed.isReady) {
  4645. @@ -253,7 +253,7 @@ import scala.util.{ Failure, Success, Try }
  4646. }
  4647. }
  4648.  
  4649. - val inboundClosed = TransferPhase(outbound || inboundHalfClosed) { () ⇒
  4650. + val inboundClosed: TransferPhase = TransferPhase(outbound || inboundHalfClosed) { () ⇒
  4651. if (tracing) log.debug("inboundClosed")
  4652. val continue = doInbound(isOutboundClosed = false, inboundHalfClosed)
  4653. if (continue) {
  4654. @@ -422,7 +422,7 @@ import scala.util.{ Failure, Success, Try }
  4655. }
  4656. }
  4657.  
  4658. - override def receive = inputBunch.subreceive.orElse[Any, Unit](outputBunch.subreceive)
  4659. + override def receive: PartialFunction[Any, Unit] = inputBunch.subreceive.orElse[Any, Unit](outputBunch.subreceive)
  4660.  
  4661. initialPhase(2, bidirectional)
  4662.  
  4663. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/TcpStages.scala b/akka-stream/src/main/scala/akka/stream/impl/io/TcpStages.scala
  4664. index 3822736478..ed1107bab4 100644
  4665. --- a/akka-stream/src/main/scala/akka/stream/impl/io/TcpStages.scala
  4666. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/TcpStages.scala
  4667. @@ -42,7 +42,7 @@ import scala.concurrent.{ Future, Promise }
  4668. import ConnectionSourceStage._
  4669.  
  4670. val out: Outlet[StreamTcp.IncomingConnection] = Outlet("IncomingConnections.out")
  4671. - override def initialAttributes = Attributes.name("ConnectionSource")
  4672. + override def initialAttributes: Attributes = Attributes.name("ConnectionSource")
  4673. val shape: SourceShape[StreamTcp.IncomingConnection] = SourceShape(out)
  4674.  
  4675. // TODO: Timeout on bind
  4676. @@ -52,9 +52,9 @@ import scala.concurrent.{ Future, Promise }
  4677. val logic = new TimerGraphStageLogic(shape) {
  4678. implicit def self: ActorRef = stageActor.ref
  4679.  
  4680. - val connectionFlowsAwaitingInitialization = new AtomicLong()
  4681. + val connectionFlowsAwaitingInitialization: AtomicLong = new AtomicLong()
  4682. var listener: ActorRef = _
  4683. - val unbindPromise = Promise[Unit]()
  4684. + val unbindPromise: Promise[Unit] = Promise[Unit]()
  4685. var unbindStarted = false
  4686.  
  4687. override def preStart(): Unit = {
  4688. @@ -305,7 +305,7 @@ private[stream] object ConnectionSourceStage {
  4689. } else completeStage()
  4690. }
  4691.  
  4692. - val readHandler = new OutHandler {
  4693. + val readHandler: OutHandler = new OutHandler {
  4694. override def onPull(): Unit = {
  4695. connection ! ResumeReading
  4696. }
  4697. @@ -373,7 +373,7 @@ private[stream] object ConnectionSourceStage {
  4698.  
  4699. val bytesIn: Inlet[ByteString] = Inlet("IncomingTCP.in")
  4700. val bytesOut: Outlet[ByteString] = Outlet("IncomingTCP.out")
  4701. - override def initialAttributes = Attributes.name("IncomingConnection")
  4702. + override def initialAttributes: Attributes = Attributes.name("IncomingConnection")
  4703. val shape: FlowShape[ByteString, ByteString] = FlowShape(bytesIn, bytesOut)
  4704.  
  4705. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = {
  4706. @@ -383,7 +383,7 @@ private[stream] object ConnectionSourceStage {
  4707. new TcpStreamLogic(shape, Inbound(connection, halfClose, ioSettings), remoteAddress)
  4708. }
  4709.  
  4710. - override def toString = s"TCP-from($remoteAddress)"
  4711. + override def toString: String = s"TCP-from($remoteAddress)"
  4712. }
  4713.  
  4714. /**
  4715. @@ -403,7 +403,7 @@ private[stream] object ConnectionSourceStage {
  4716.  
  4717. val bytesIn: Inlet[ByteString] = Inlet("IncomingTCP.in")
  4718. val bytesOut: Outlet[ByteString] = Outlet("IncomingTCP.out")
  4719. - override def initialAttributes = Attributes.name("OutgoingConnection")
  4720. + override def initialAttributes: Attributes = Attributes.name("OutgoingConnection")
  4721. val shape: FlowShape[ByteString, ByteString] = FlowShape(bytesIn, bytesOut)
  4722.  
  4723. override def createLogicAndMaterializedValue(inheritedAttributes: Attributes): (GraphStageLogic, Future[StreamTcp.OutgoingConnection]) = {
  4724. @@ -425,7 +425,7 @@ private[stream] object ConnectionSourceStage {
  4725. (logic, localAddressPromise.future.map(OutgoingConnection(remoteAddress, _))(ExecutionContexts.sameThreadExecutionContext))
  4726. }
  4727.  
  4728. - override def toString = s"TCP-to($remoteAddress)"
  4729. + override def toString: String = s"TCP-to($remoteAddress)"
  4730. }
  4731.  
  4732. /** INTERNAL API */
  4733. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/compression/CompressionUtils.scala b/akka-stream/src/main/scala/akka/stream/impl/io/compression/CompressionUtils.scala
  4734. index b992d8c499..1dd3f1a994 100644
  4735. --- a/akka-stream/src/main/scala/akka/stream/impl/io/compression/CompressionUtils.scala
  4736. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/compression/CompressionUtils.scala
  4737. @@ -20,7 +20,7 @@ import akka.util.ByteString
  4738. Flow.fromGraph {
  4739. new SimpleLinearGraphStage[ByteString] {
  4740. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with InHandler with OutHandler {
  4741. - val compressor = newCompressor()
  4742. + val compressor: Compressor = newCompressor()
  4743.  
  4744. override def onPush(): Unit = {
  4745. val data = compressor.compressAndFlush(grab(in))
  4746. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateCompressor.scala b/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateCompressor.scala
  4747. index cdd03265d1..d23432e002 100644
  4748. --- a/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateCompressor.scala
  4749. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateCompressor.scala
  4750. @@ -14,7 +14,7 @@ import scala.annotation.tailrec
  4751. @InternalApi private[akka] class DeflateCompressor(level: Int = Deflater.BEST_COMPRESSION, nowrap: Boolean = false) extends Compressor {
  4752. import DeflateCompressor._
  4753.  
  4754. - protected lazy val deflater = new Deflater(level, nowrap)
  4755. + protected lazy val deflater: Deflater = new Deflater(level, nowrap)
  4756.  
  4757. override final def compressAndFlush(input: ByteString): ByteString = {
  4758. val buffer = newTempBuffer(input.size)
  4759. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressor.scala b/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressor.scala
  4760. index 4404e2e577..5d28901bf2 100644
  4761. --- a/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressor.scala
  4762. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/compression/DeflateDecompressor.scala
  4763. @@ -12,7 +12,7 @@ import akka.stream.Attributes
  4764. @InternalApi private[akka] class DeflateDecompressor(maxBytesPerChunk: Int)
  4765. extends DeflateDecompressorBase(maxBytesPerChunk) {
  4766.  
  4767. - override def createLogic(attr: Attributes) = new DecompressorParsingLogic {
  4768. + override def createLogic(attr: Attributes): DeflateDecompressor.this.DecompressorParsingLogic = new DecompressorParsingLogic {
  4769. override val inflater: Inflater = new Inflater()
  4770.  
  4771. override case object inflating extends Inflate(noPostProcessing = true) {
  4772. diff --git a/akka-stream/src/main/scala/akka/stream/impl/io/compression/GzipCompressor.scala b/akka-stream/src/main/scala/akka/stream/impl/io/compression/GzipCompressor.scala
  4773. index 9b968a8c48..bac849ac29 100644
  4774. --- a/akka-stream/src/main/scala/akka/stream/impl/io/compression/GzipCompressor.scala
  4775. +++ b/akka-stream/src/main/scala/akka/stream/impl/io/compression/GzipCompressor.scala
  4776. @@ -10,7 +10,7 @@ import akka.util.ByteString
  4777.  
  4778. /** INTERNAL API */
  4779. @InternalApi private[akka] class GzipCompressor(compressionLevel: Int = Deflater.BEST_COMPRESSION) extends DeflateCompressor(compressionLevel, true) {
  4780. - override protected lazy val deflater = new Deflater(compressionLevel, true)
  4781. + override protected lazy val deflater: Deflater = new Deflater(compressionLevel, true)
  4782. private val checkSum = new CRC32 // CRC32 of uncompressed data
  4783. private var headerSent = false
  4784. private var bytesRead = 0L
  4785. diff --git a/akka-stream/src/main/scala/akka/stream/javadsl/BidiFlow.scala b/akka-stream/src/main/scala/akka/stream/javadsl/BidiFlow.scala
  4786. index cff4f69c47..f4d38cf058 100644
  4787. --- a/akka-stream/src/main/scala/akka/stream/javadsl/BidiFlow.scala
  4788. +++ b/akka-stream/src/main/scala/akka/stream/javadsl/BidiFlow.scala
  4789. @@ -8,6 +8,7 @@ import akka.japi.function
  4790. import akka.stream._
  4791.  
  4792. import scala.concurrent.duration.FiniteDuration
  4793. +import akka.stream.impl.TraversalBuilder
  4794.  
  4795. object BidiFlow {
  4796.  
  4797. @@ -96,8 +97,8 @@ object BidiFlow {
  4798. }
  4799.  
  4800. final class BidiFlow[-I1, +O1, -I2, +O2, +Mat](delegate: scaladsl.BidiFlow[I1, O1, I2, O2, Mat]) extends Graph[BidiShape[I1, O1, I2, O2], Mat] {
  4801. - override def traversalBuilder = delegate.traversalBuilder
  4802. - override def shape = delegate.shape
  4803. + override def traversalBuilder: TraversalBuilder = delegate.traversalBuilder
  4804. + override def shape: BidiShape[I1, O1, I2, O2] = delegate.shape
  4805.  
  4806. def asScala: scaladsl.BidiFlow[I1, O1, I2, O2, Mat] = delegate
  4807.  
  4808. diff --git a/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala b/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala
  4809. index 680acfbced..84554a67e8 100644
  4810. --- a/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala
  4811. +++ b/akka-stream/src/main/scala/akka/stream/javadsl/Flow.scala
  4812. @@ -17,6 +17,7 @@ import java.util.Comparator
  4813. import java.util.concurrent.CompletionStage
  4814.  
  4815. import scala.compat.java8.FutureConverters._
  4816. +import akka.stream.impl.{ LinearTraversalBuilder, TraversalBuilder }
  4817.  
  4818. object Flow {
  4819.  
  4820. @@ -206,7 +207,7 @@ final class Flow[-In, +Out, +Mat](delegate: scaladsl.Flow[In, Out, Mat]) extends
  4821. import scala.collection.JavaConverters._
  4822.  
  4823. override def shape: FlowShape[In, Out] = delegate.shape
  4824. - override def traversalBuilder = delegate.traversalBuilder
  4825. + override def traversalBuilder: LinearTraversalBuilder = delegate.traversalBuilder
  4826.  
  4827. override def toString: String = delegate.toString
  4828.  
  4829. @@ -2355,8 +2356,8 @@ object RunnableGraph {
  4830.  
  4831. /** INTERNAL API */
  4832. private final class RunnableGraphAdapter[Mat](runnable: scaladsl.RunnableGraph[Mat]) extends RunnableGraph[Mat] {
  4833. - override def shape = ClosedShape
  4834. - override def traversalBuilder = runnable.traversalBuilder
  4835. + override def shape: ClosedShape.type = ClosedShape
  4836. + override def traversalBuilder: TraversalBuilder = runnable.traversalBuilder
  4837.  
  4838. override def toString: String = runnable.toString
  4839.  
  4840. diff --git a/akka-stream/src/main/scala/akka/stream/javadsl/Keep.scala b/akka-stream/src/main/scala/akka/stream/javadsl/Keep.scala
  4841. index 7eb2d8188b..cab463b92b 100644
  4842. --- a/akka-stream/src/main/scala/akka/stream/javadsl/Keep.scala
  4843. +++ b/akka-stream/src/main/scala/akka/stream/javadsl/Keep.scala
  4844. @@ -8,10 +8,10 @@ import akka.japi.function
  4845. import akka.japi.Pair
  4846.  
  4847. object Keep {
  4848. - private val _left = new function.Function2[Any, Any, Any] with ((Any, Any) ⇒ Any) { def apply(l: Any, r: Any) = l }
  4849. - private val _right = new function.Function2[Any, Any, Any] with ((Any, Any) ⇒ Any) { def apply(l: Any, r: Any) = r }
  4850. - private val _both = new function.Function2[Any, Any, Any] with ((Any, Any) ⇒ Any) { def apply(l: Any, r: Any) = new akka.japi.Pair(l, r) }
  4851. - private val _none = new function.Function2[Any, Any, NotUsed] with ((Any, Any) ⇒ NotUsed) { def apply(l: Any, r: Any) = NotUsed }
  4852. + private val _left = new function.Function2[Any, Any, Any] with ((Any, Any) ⇒ Any) { def apply(l: Any, r: Any): Any = l }
  4853. + private val _right = new function.Function2[Any, Any, Any] with ((Any, Any) ⇒ Any) { def apply(l: Any, r: Any): Any = r }
  4854. + private val _both = new function.Function2[Any, Any, Any] with ((Any, Any) ⇒ Any) { def apply(l: Any, r: Any): Pair[Any, Any] = new akka.japi.Pair(l, r) }
  4855. + private val _none = new function.Function2[Any, Any, NotUsed] with ((Any, Any) ⇒ NotUsed) { def apply(l: Any, r: Any): NotUsed.type = NotUsed }
  4856.  
  4857. def left[L, R]: function.Function2[L, R, L] = _left.asInstanceOf[function.Function2[L, R, L]]
  4858. def right[L, R]: function.Function2[L, R, R] = _right.asInstanceOf[function.Function2[L, R, R]]
  4859. diff --git a/akka-stream/src/main/scala/akka/stream/javadsl/Tcp.scala b/akka-stream/src/main/scala/akka/stream/javadsl/Tcp.scala
  4860. index 46bf553dc3..96d9fab556 100644
  4861. --- a/akka-stream/src/main/scala/akka/stream/javadsl/Tcp.scala
  4862. +++ b/akka-stream/src/main/scala/akka/stream/javadsl/Tcp.scala
  4863. @@ -103,7 +103,7 @@ object Tcp extends ExtensionId[Tcp] with ExtensionIdProvider {
  4864.  
  4865. override def get(system: ActorSystem): Tcp = super.get(system)
  4866.  
  4867. - def lookup() = Tcp
  4868. + def lookup(): Tcp.type = Tcp
  4869.  
  4870. def createExtension(system: ExtendedActorSystem): Tcp = new Tcp(system)
  4871. }
  4872. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Compression.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Compression.scala
  4873. index 7d2435ad48..add8049673 100644
  4874. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Compression.scala
  4875. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Compression.scala
  4876. @@ -10,7 +10,7 @@ import akka.stream.impl.io.compression._
  4877. import akka.util.ByteString
  4878.  
  4879. object Compression {
  4880. - final val MaxBytesPerChunkDefault = 64 * 1024
  4881. + final val MaxBytesPerChunkDefault: Int = 64 * 1024
  4882.  
  4883. /**
  4884. * Creates a flow that gzip-compresses a stream of ByteStrings. Note that the compressor
  4885. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/CoupledTerminationFlow.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/CoupledTerminationFlow.scala
  4886. index dc8aeabc96..03c093a689 100644
  4887. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/CoupledTerminationFlow.scala
  4888. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/CoupledTerminationFlow.scala
  4889. @@ -75,7 +75,7 @@ private[stream] class CoupledTerminationBidi[I, O] extends GraphStage[BidiShape[
  4890.  
  4891. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) {
  4892.  
  4893. - val handler1 = new InHandler with OutHandler {
  4894. + val handler1: InHandler with OutHandler = new InHandler with OutHandler {
  4895. override def onPush(): Unit = push(out1, grab(in1))
  4896. override def onPull(): Unit = pull(in1)
  4897.  
  4898. @@ -84,7 +84,7 @@ private[stream] class CoupledTerminationBidi[I, O] extends GraphStage[BidiShape[
  4899. override def onUpstreamFailure(ex: Throwable): Unit = failStage(ex)
  4900. }
  4901.  
  4902. - val handler2 = new InHandler with OutHandler {
  4903. + val handler2: InHandler with OutHandler = new InHandler with OutHandler {
  4904. override def onPush(): Unit = push(out2, grab(in2))
  4905. override def onPull(): Unit = pull(in2)
  4906.  
  4907. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala
  4908. index 47b749bd68..ec28cd4d86 100644
  4909. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala
  4910. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Flow.scala
  4911. @@ -510,7 +510,7 @@ object RunnableGraph {
  4912. * Flow with attached input and output, can be executed.
  4913. */
  4914. final case class RunnableGraph[+Mat](override val traversalBuilder: TraversalBuilder) extends Graph[ClosedShape, Mat] {
  4915. - override def shape = ClosedShape
  4916. + override def shape: ClosedShape.type = ClosedShape
  4917.  
  4918. /**
  4919. * Transform only the materialized value of this RunnableGraph, leaving all other properties as they were.
  4920. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Framing.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Framing.scala
  4921. index 3e7141eb80..9063b4cd35 100644
  4922. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Framing.scala
  4923. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Framing.scala
  4924. @@ -162,7 +162,7 @@ object Framing {
  4925. }
  4926.  
  4927. private class SimpleFramingProtocolEncoder(maximumMessageLength: Long) extends SimpleLinearGraphStage[ByteString] {
  4928. - override def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) with InHandler with OutHandler {
  4929. + override def createLogic(inheritedAttributes: Attributes): GraphStageLogic with InHandler with OutHandler = new GraphStageLogic(shape) with InHandler with OutHandler {
  4930. setHandlers(in, out, this)
  4931.  
  4932. override def onPush(): Unit = {
  4933. @@ -184,8 +184,8 @@ object Framing {
  4934. private class DelimiterFramingStage(val separatorBytes: ByteString, val maximumLineBytes: Int, val allowTruncation: Boolean)
  4935. extends GraphStage[FlowShape[ByteString, ByteString]] {
  4936.  
  4937. - val in = Inlet[ByteString]("DelimiterFramingStage.in")
  4938. - val out = Outlet[ByteString]("DelimiterFramingStage.out")
  4939. + val in: Inlet[ByteString] = Inlet[ByteString]("DelimiterFramingStage.in")
  4940. + val out: Outlet[ByteString] = Outlet[ByteString]("DelimiterFramingStage.out")
  4941. override val shape: FlowShape[ByteString, ByteString] = FlowShape(in, out)
  4942.  
  4943. override def initialAttributes: Attributes = DefaultAttributes.delimiterFraming
  4944. @@ -284,8 +284,8 @@ object Framing {
  4945. case ByteOrder.LITTLE_ENDIAN ⇒ littleEndianDecoder
  4946. }
  4947.  
  4948. - val in = Inlet[ByteString]("LengthFieldFramingStage.in")
  4949. - val out = Outlet[ByteString]("LengthFieldFramingStage.out")
  4950. + val in: Inlet[ByteString] = Inlet[ByteString]("LengthFieldFramingStage.in")
  4951. + val out: Outlet[ByteString] = Outlet[ByteString]("LengthFieldFramingStage.out")
  4952. override val shape: FlowShape[ByteString, ByteString] = FlowShape(in, out)
  4953.  
  4954. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with InHandler with OutHandler {
  4955. @@ -343,7 +343,7 @@ object Framing {
  4956. tryPushFrame()
  4957. }
  4958.  
  4959. - override def onPull() = tryPushFrame()
  4960. + override def onPull(): Unit = tryPushFrame()
  4961.  
  4962. override def onUpstreamFinish(): Unit = {
  4963. if (buffer.isEmpty) {
  4964. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Graph.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Graph.scala
  4965. index 82ffa83e3a..0e6374a276 100644
  4966. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Graph.scala
  4967. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Graph.scala
  4968. @@ -80,7 +80,7 @@ final class Merge[T](val inputPorts: Int, val eagerComplete: Boolean) extends Gr
  4969.  
  4970. val in: immutable.IndexedSeq[Inlet[T]] = Vector.tabulate(inputPorts)(i ⇒ Inlet[T]("Merge.in" + i))
  4971. val out: Outlet[T] = Outlet[T]("Merge.out")
  4972. - override def initialAttributes = DefaultAttributes.merge
  4973. + override def initialAttributes: Attributes = DefaultAttributes.merge
  4974. override val shape: UniformFanInShape[T, T] = UniformFanInShape(out, in: _*)
  4975.  
  4976. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with OutHandler {
  4977. @@ -131,7 +131,7 @@ final class Merge[T](val inputPorts: Int, val eagerComplete: Boolean) extends Gr
  4978. } else pendingQueue.enqueue(i)
  4979. }
  4980.  
  4981. - override def onUpstreamFinish() =
  4982. + override def onUpstreamFinish(): Unit =
  4983. if (eagerComplete) {
  4984. var ix2 = 0
  4985. while (ix2 < in.size) {
  4986. @@ -165,7 +165,7 @@ object MergePreferred {
  4987. override protected def construct(init: Init[T]): FanInShape[T] = new MergePreferredShape(secondaryPorts, init)
  4988. override def deepCopy(): MergePreferredShape[T] = super.deepCopy().asInstanceOf[MergePreferredShape[T]]
  4989.  
  4990. - val preferred = newInlet[T]("preferred")
  4991. + val preferred: Inlet[T] = newInlet[T]("preferred")
  4992. }
  4993.  
  4994. /**
  4995. @@ -195,7 +195,7 @@ object MergePreferred {
  4996. final class MergePreferred[T](val secondaryPorts: Int, val eagerComplete: Boolean) extends GraphStage[MergePreferred.MergePreferredShape[T]] {
  4997. require(secondaryPorts >= 1, "A MergePreferred must have 1 or more secondary input ports")
  4998.  
  4999. - override def initialAttributes = DefaultAttributes.mergePreferred
  5000. + override def initialAttributes: Attributes = DefaultAttributes.mergePreferred
  5001. override val shape: MergePreferred.MergePreferredShape[T] =
  5002. new MergePreferred.MergePreferredShape(secondaryPorts, "MergePreferred")
  5003.  
  5004. @@ -204,7 +204,7 @@ final class MergePreferred[T](val secondaryPorts: Int, val eagerComplete: Boolea
  5005. def preferred: Inlet[T] = shape.preferred
  5006.  
  5007. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) {
  5008. - var openInputs = secondaryPorts + 1
  5009. + var openInputs: Int = secondaryPorts + 1
  5010. def onComplete(): Unit = {
  5011. openInputs -= 1
  5012. if (eagerComplete || openInputs == 0) completeStage()
  5013. @@ -217,7 +217,7 @@ final class MergePreferred[T](val secondaryPorts: Int, val eagerComplete: Boolea
  5014.  
  5015. setHandler(out, eagerTerminateOutput)
  5016.  
  5017. - val pullMe = Array.tabulate(secondaryPorts)(i ⇒ {
  5018. + val pullMe: Array[() ⇒ Unit] = Array.tabulate(secondaryPorts)(i ⇒ {
  5019. val port = in(i)
  5020. () ⇒ tryPull(port)
  5021. })
  5022. @@ -243,7 +243,7 @@ final class MergePreferred[T](val secondaryPorts: Int, val eagerComplete: Boolea
  5023. tryPull(preferred)
  5024. }
  5025.  
  5026. - val emitted = () ⇒ {
  5027. + val emitted: () ⇒ Unit = () ⇒ {
  5028. preferredEmitting -= 1
  5029. if (isAvailable(preferred)) emitPreferred()
  5030. else if (preferredEmitting == 0) emitSecondary()
  5031. @@ -499,9 +499,9 @@ final class MergeSorted[T: Ordering] extends GraphStage[FanInShape2[T, T, T]] {
  5032. private val right = Inlet[T]("right")
  5033. private val out = Outlet[T]("out")
  5034.  
  5035. - override val shape = new FanInShape2(left, right, out)
  5036. + override val shape: FanInShape2[T, T, T] = new FanInShape2(left, right, out)
  5037.  
  5038. - override def createLogic(attr: Attributes) = new GraphStageLogic(shape) {
  5039. + override def createLogic(attr: Attributes): GraphStageLogic = new GraphStageLogic(shape) {
  5040. import Ordering.Implicits._
  5041. setHandler(left, ignoreTerminateInput)
  5042. setHandler(right, ignoreTerminateInput)
  5043. @@ -514,12 +514,12 @@ final class MergeSorted[T: Ordering] extends GraphStage[FanInShape2[T, T, T]] {
  5044. if (l < r) { other = r; emit(out, l, readL) }
  5045. else { other = l; emit(out, r, readR) }
  5046.  
  5047. - val dispatchR = dispatch(other, _: T)
  5048. - val dispatchL = dispatch(_: T, other)
  5049. - val passR = () ⇒ emit(out, other, () ⇒ { nullOut(); passAlong(right, out, doPull = true) })
  5050. - val passL = () ⇒ emit(out, other, () ⇒ { nullOut(); passAlong(left, out, doPull = true) })
  5051. - val readR = () ⇒ read(right)(dispatchR, passL)
  5052. - val readL = () ⇒ read(left)(dispatchL, passR)
  5053. + val dispatchR: T ⇒ Unit = dispatch(other, _: T)
  5054. + val dispatchL: T ⇒ Unit = dispatch(_: T, other)
  5055. + val passR: () ⇒ Unit = () ⇒ emit(out, other, () ⇒ { nullOut(); passAlong(right, out, doPull = true) })
  5056. + val passL: () ⇒ Unit = () ⇒ emit(out, other, () ⇒ { nullOut(); passAlong(left, out, doPull = true) })
  5057. + val readR: () ⇒ Unit = () ⇒ read(right)(dispatchR, passL)
  5058. + val readL: () ⇒ Unit = () ⇒ read(left)(dispatchL, passR)
  5059.  
  5060. override def preStart(): Unit = {
  5061. // all fan-in stages need to eagerly pull all inputs to get cycles started
  5062. @@ -562,7 +562,7 @@ final class Broadcast[T](val outputPorts: Int, val eagerCancel: Boolean) extends
  5063. require(outputPorts >= 1, "A Broadcast must have one or more output ports")
  5064. val in: Inlet[T] = Inlet[T]("Broadcast.in")
  5065. val out: immutable.IndexedSeq[Outlet[T]] = Vector.tabulate(outputPorts)(i ⇒ Outlet[T]("Broadcast.out" + i))
  5066. - override def initialAttributes = DefaultAttributes.broadcast
  5067. + override def initialAttributes: Attributes = DefaultAttributes.broadcast
  5068. override val shape: UniformFanOutShape[T, T] = UniformFanOutShape(in, out: _*)
  5069.  
  5070. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with InHandler {
  5071. @@ -604,7 +604,7 @@ final class Broadcast[T](val outputPorts: Int, val eagerCancel: Boolean) extends
  5072. tryPull()
  5073. }
  5074.  
  5075. - override def onDownstreamFinish() = {
  5076. + override def onDownstreamFinish(): Unit = {
  5077. if (eagerCancel) completeStage()
  5078. else {
  5079. downstreamsRunning -= 1
  5080. @@ -665,7 +665,7 @@ final class Partition[T](val outputPorts: Int, val partitioner: T ⇒ Int) exten
  5081. private var outPendingIdx: Int = _
  5082. private var downstreamRunning = outputPorts
  5083.  
  5084. - def onPush() = {
  5085. + def onPush(): Unit = {
  5086. val elem = grab(in)
  5087. val idx = partitioner(elem)
  5088. if (idx < 0 || idx >= outputPorts) {
  5089. @@ -693,7 +693,7 @@ final class Partition[T](val outputPorts: Int, val partitioner: T ⇒ Int) exten
  5090. out.zipWithIndex.foreach {
  5091. case (o, idx) ⇒
  5092. setHandler(o, new OutHandler {
  5093. - override def onPull() = {
  5094. + override def onPull(): Unit = {
  5095.  
  5096. if (outPendingElem != null) {
  5097. val elem = outPendingElem.asInstanceOf[T]
  5098. @@ -727,7 +727,7 @@ final class Partition[T](val outputPorts: Int, val partitioner: T ⇒ Int) exten
  5099. }
  5100. }
  5101.  
  5102. - override def toString = s"Partition($outputPorts)"
  5103. + override def toString: String = s"Partition($outputPorts)"
  5104.  
  5105. }
  5106.  
  5107. @@ -764,7 +764,7 @@ final class Balance[T](val outputPorts: Int, val waitForAllDownstreams: Boolean)
  5108. require(outputPorts >= 1, "A Balance must have one or more output ports")
  5109. val in: Inlet[T] = Inlet[T]("Balance.in")
  5110. val out: immutable.IndexedSeq[Outlet[T]] = Vector.tabulate(outputPorts)(i ⇒ Outlet[T]("Balance.out" + i))
  5111. - override def initialAttributes = DefaultAttributes.balance
  5112. + override def initialAttributes: Attributes = DefaultAttributes.balance
  5113. override val shape: UniformFanOutShape[T, T] = UniformFanOutShape[T, T](in, out: _*)
  5114.  
  5115. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic = new GraphStageLogic(shape) with InHandler {
  5116. @@ -815,7 +815,7 @@ final class Balance[T](val outputPorts: Int, val waitForAllDownstreams: Boolean)
  5117. } else pendingQueue.enqueue(o)
  5118. }
  5119.  
  5120. - override def onDownstreamFinish() = {
  5121. + override def onDownstreamFinish(): Unit = {
  5122. downstreamsRunning -= 1
  5123. if (downstreamsRunning == 0) completeStage()
  5124. else if (!hasPulled && needDownstreamPulls > 0) {
  5125. @@ -921,7 +921,7 @@ object ZipN {
  5126. /**
  5127. * Create a new `ZipN`.
  5128. */
  5129. - def apply[A](n: Int) = new ZipN[A](n)
  5130. + def apply[A](n: Int): ZipN[A] = new ZipN[A](n)
  5131. }
  5132.  
  5133. /**
  5134. @@ -938,7 +938,7 @@ object ZipN {
  5135. * '''Cancels when''' downstream cancels
  5136. */
  5137. final class ZipN[A](n: Int) extends ZipWithN[A, immutable.Seq[A]](ConstantFun.scalaIdentityFunction)(n) {
  5138. - override def initialAttributes = DefaultAttributes.zipN
  5139. + override def initialAttributes: Attributes = DefaultAttributes.zipN
  5140. override def toString = "ZipN"
  5141. }
  5142.  
  5143. @@ -946,7 +946,7 @@ object ZipWithN {
  5144. /**
  5145. * Create a new `ZipWithN`.
  5146. */
  5147. - def apply[A, O](zipper: immutable.Seq[A] ⇒ O)(n: Int) = new ZipWithN[A, O](zipper)(n)
  5148. + def apply[A, O](zipper: immutable.Seq[A] ⇒ O)(n: Int): ZipWithN[A, O] = new ZipWithN[A, O](zipper)(n)
  5149. }
  5150.  
  5151. /**
  5152. @@ -963,8 +963,8 @@ object ZipWithN {
  5153. * '''Cancels when''' downstream cancels
  5154. */
  5155. class ZipWithN[A, O](zipper: immutable.Seq[A] ⇒ O)(n: Int) extends GraphStage[UniformFanInShape[A, O]] {
  5156. - override def initialAttributes = DefaultAttributes.zipWithN
  5157. - override val shape = new UniformFanInShape[A, O](n)
  5158. + override def initialAttributes: Attributes = DefaultAttributes.zipWithN
  5159. + override val shape: UniformFanInShape[A, O] = new UniformFanInShape[A, O](n)
  5160. def out: Outlet[O] = shape.out
  5161.  
  5162. @deprecated("use `shape.inlets` or `shape.in(id)` instead", "2.5.5")
  5163. @@ -975,8 +975,8 @@ class ZipWithN[A, O](zipper: immutable.Seq[A] ⇒ O)(n: Int) extends GraphStage[
  5164. // Without this field the completion signalling would take one extra pull
  5165. var willShutDown = false
  5166.  
  5167. - val grabInlet = grab[A] _
  5168. - val pullInlet = pull[A] _
  5169. + val grabInlet: Inlet[A] ⇒ A = grab[A] _
  5170. + val pullInlet: Inlet[A] ⇒ Unit = pull[A] _
  5171.  
  5172. private def pushAll(): Unit = {
  5173. push(out, zipper(shape.inlets.map(grabInlet)))
  5174. @@ -1041,10 +1041,10 @@ final class Concat[T](val inputPorts: Int) extends GraphStage[UniformFanInShape[
  5175. require(inputPorts > 1, "A Concat must have more than 1 input ports")
  5176. val in: immutable.IndexedSeq[Inlet[T]] = Vector.tabulate(inputPorts)(i ⇒ Inlet[T]("Concat.in" + i))
  5177. val out: Outlet[T] = Outlet[T]("Concat.out")
  5178. - override def initialAttributes = DefaultAttributes.concat
  5179. + override def initialAttributes: Attributes = DefaultAttributes.concat
  5180. override val shape: UniformFanInShape[T, T] = UniformFanInShape(out, in: _*)
  5181.  
  5182. - override def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) with OutHandler {
  5183. + override def createLogic(inheritedAttributes: Attributes): GraphStageLogic with OutHandler = new GraphStageLogic(shape) with OutHandler {
  5184. var activeStream: Int = 0
  5185.  
  5186. {
  5187. @@ -1054,11 +1054,11 @@ final class Concat[T](val inputPorts: Int) extends GraphStage[UniformFanInShape[
  5188. val i = in(idxx)
  5189. val idx = idxx // close over val
  5190. setHandler(i, new InHandler {
  5191. - override def onPush() = {
  5192. + override def onPush(): Unit = {
  5193. push(out, grab(i))
  5194. }
  5195.  
  5196. - override def onUpstreamFinish() = {
  5197. + override def onUpstreamFinish(): Unit = {
  5198. if (idx == activeStream) {
  5199. activeStream += 1
  5200. // Skip closed inputs
  5201. @@ -1072,7 +1072,7 @@ final class Concat[T](val inputPorts: Int) extends GraphStage[UniformFanInShape[
  5202. }
  5203. }
  5204.  
  5205. - def onPull() = pull(in(activeStream))
  5206. + def onPull(): Unit = pull(in(activeStream))
  5207.  
  5208. setHandler(out, this)
  5209. }
  5210. @@ -1082,7 +1082,7 @@ final class Concat[T](val inputPorts: Int) extends GraphStage[UniformFanInShape[
  5211.  
  5212. object OrElse {
  5213. private val singleton = new OrElse[Nothing]
  5214. - def apply[T]() = singleton.asInstanceOf[OrElse[T]]
  5215. + def apply[T](): OrElse[T] = singleton.asInstanceOf[OrElse[T]]
  5216. }
  5217.  
  5218. /**
  5219. @@ -1104,9 +1104,9 @@ object OrElse {
  5220. * '''Cancels when''' downstream cancels
  5221. */
  5222. private[stream] final class OrElse[T] extends GraphStage[UniformFanInShape[T, T]] {
  5223. - val primary = Inlet[T]("OrElse.primary")
  5224. - val secondary = Inlet[T]("OrElse.secondary")
  5225. - val out = Outlet[T]("OrElse.out")
  5226. + val primary: Inlet[T] = Inlet[T]("OrElse.primary")
  5227. + val secondary: Inlet[T] = Inlet[T]("OrElse.secondary")
  5228. + val out: Outlet[T] = Outlet[T]("OrElse.out")
  5229.  
  5230. override val shape: UniformFanInShape[T, T] = UniformFanInShape(out, primary, secondary)
  5231.  
  5232. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Hub.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Hub.scala
  5233. index 24e778b10e..ab00ad439e 100644
  5234. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Hub.scala
  5235. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Hub.scala
  5236. @@ -375,7 +375,7 @@ private[akka] class BroadcastHub[T](bufferSize: Int) extends GraphStageWithMater
  5237.  
  5238. private[this] val callbackPromise: Promise[AsyncCallback[HubEvent]] = Promise()
  5239. private[this] val noRegistrationsState = Open(callbackPromise.future, Nil)
  5240. - val state = new AtomicReference[HubState](noRegistrationsState)
  5241. + val state: AtomicReference[BroadcastHub.this.HubState] = new AtomicReference[HubState](noRegistrationsState)
  5242.  
  5243. // Start from values that will almost immediately overflow. This has no effect on performance, any starting
  5244. // number will do, however, this protects from regressions as these values *almost surely* overflow and fail
  5245. @@ -874,7 +874,7 @@ object PartitionHub {
  5246. }
  5247.  
  5248. object ConsumerQueue {
  5249. - val empty = ConsumerQueue(Queue.empty, 0)
  5250. + val empty: ConsumerQueue = ConsumerQueue(Queue.empty, 0)
  5251. }
  5252.  
  5253. final case class ConsumerQueue(queue: Queue[Any], size: Int) {
  5254. @@ -1012,7 +1012,7 @@ object PartitionHub {
  5255.  
  5256. private val callbackPromise: Promise[AsyncCallback[HubEvent]] = Promise()
  5257. private val noRegistrationsState = Open(callbackPromise.future, Nil)
  5258. - val state = new AtomicReference[HubState](noRegistrationsState)
  5259. + val state: AtomicReference[HubState] = new AtomicReference[HubState](noRegistrationsState)
  5260. private var initialized = false
  5261.  
  5262. private val queue = createQueue()
  5263. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/JsonFraming.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/JsonFraming.scala
  5264. index 018053e5e5..d32a10818b 100644
  5265. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/JsonFraming.scala
  5266. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/JsonFraming.scala
  5267. @@ -44,7 +44,7 @@ object JsonFraming {
  5268.  
  5269. override protected def initialAttributes: Attributes = Attributes.name("JsonFraming.objectScanner")
  5270.  
  5271. - override def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) with InHandler with OutHandler {
  5272. + override def createLogic(inheritedAttributes: Attributes): GraphStageLogic with InHandler with OutHandler = new GraphStageLogic(shape) with InHandler with OutHandler {
  5273. private val buffer = new JsonObjectParser(maximumObjectLength)
  5274.  
  5275. setHandlers(in, out, this)
  5276. @@ -64,7 +64,7 @@ object JsonFraming {
  5277. }
  5278. }
  5279.  
  5280. - def tryPopBuffer() = {
  5281. + def tryPopBuffer(): Unit = {
  5282. try buffer.poll() match {
  5283. case Some(json) ⇒ push(out, json)
  5284. case _ ⇒ if (isClosed(in)) completeStage() else pull(in)
  5285. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Restart.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Restart.scala
  5286. index 6727de91a1..d5e42a85f9 100644
  5287. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Restart.scala
  5288. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Restart.scala
  5289. @@ -9,6 +9,7 @@ import akka.stream._
  5290. import akka.stream.stage.{ GraphStage, InHandler, OutHandler, TimerGraphStageLogicWithLogging }
  5291.  
  5292. import scala.concurrent.duration.FiniteDuration
  5293. +import scala.concurrent.duration.Deadline
  5294.  
  5295. /**
  5296. * A RestartSource wraps a [[Source]] that gets restarted when it completes or fails.
  5297. @@ -130,15 +131,15 @@ private final class RestartWithBackoffSource[T](
  5298. onlyOnFailures: Boolean,
  5299. maxRestarts: Int) extends GraphStage[SourceShape[T]] { self ⇒
  5300.  
  5301. - val out = Outlet[T]("RestartWithBackoffSource.out")
  5302. + val out: Outlet[T] = Outlet[T]("RestartWithBackoffSource.out")
  5303.  
  5304. - override def shape = SourceShape(out)
  5305. - override def createLogic(inheritedAttributes: Attributes) = new RestartWithBackoffLogic(
  5306. + override def shape: SourceShape[T] = SourceShape(out)
  5307. + override def createLogic(inheritedAttributes: Attributes): RestartWithBackoffLogic[SourceShape[T]] = new RestartWithBackoffLogic(
  5308. "Source", shape, minBackoff, maxBackoff, randomFactor, onlyOnFailures, maxRestarts) {
  5309.  
  5310. override protected def logSource = self.getClass
  5311.  
  5312. - override protected def startGraph() = {
  5313. + override protected def startGraph(): Unit = {
  5314. val sinkIn = createSubInlet(out)
  5315. sourceFactory().runWith(sinkIn.sink)(subFusingMaterializer)
  5316. if (isAvailable(out)) {
  5317. @@ -146,7 +147,7 @@ private final class RestartWithBackoffSource[T](
  5318. }
  5319. }
  5320.  
  5321. - override protected def backoff() = {
  5322. + override protected def backoff(): Unit = {
  5323. setHandler(out, new OutHandler {
  5324. override def onPull() = ()
  5325. })
  5326. @@ -231,19 +232,19 @@ private final class RestartWithBackoffSink[T](
  5327. randomFactor: Double,
  5328. maxRestarts: Int) extends GraphStage[SinkShape[T]] { self ⇒
  5329.  
  5330. - val in = Inlet[T]("RestartWithBackoffSink.in")
  5331. + val in: Inlet[T] = Inlet[T]("RestartWithBackoffSink.in")
  5332.  
  5333. - override def shape = SinkShape(in)
  5334. - override def createLogic(inheritedAttributes: Attributes) = new RestartWithBackoffLogic(
  5335. + override def shape: SinkShape[T] = SinkShape(in)
  5336. + override def createLogic(inheritedAttributes: Attributes): RestartWithBackoffLogic[SinkShape[T]] = new RestartWithBackoffLogic(
  5337. "Sink", shape, minBackoff, maxBackoff, randomFactor, onlyOnFailures = false, maxRestarts) {
  5338. override protected def logSource = self.getClass
  5339.  
  5340. - override protected def startGraph() = {
  5341. + override protected def startGraph(): Unit = {
  5342. val sourceOut = createSubOutlet(in)
  5343. Source.fromGraph(sourceOut.source).runWith(sinkFactory())(subFusingMaterializer)
  5344. }
  5345.  
  5346. - override protected def backoff() = {
  5347. + override protected def backoff(): Unit = {
  5348. setHandler(in, new InHandler {
  5349. override def onPush() = ()
  5350. })
  5351. @@ -326,18 +327,18 @@ private final class RestartWithBackoffFlow[In, Out](
  5352. randomFactor: Double,
  5353. maxRestarts: Int) extends GraphStage[FlowShape[In, Out]] { self ⇒
  5354.  
  5355. - val in = Inlet[In]("RestartWithBackoffFlow.in")
  5356. - val out = Outlet[Out]("RestartWithBackoffFlow.out")
  5357. + val in: Inlet[In] = Inlet[In]("RestartWithBackoffFlow.in")
  5358. + val out: Outlet[Out] = Outlet[Out]("RestartWithBackoffFlow.out")
  5359.  
  5360. - override def shape = FlowShape(in, out)
  5361. - override def createLogic(inheritedAttributes: Attributes) = new RestartWithBackoffLogic(
  5362. + override def shape: FlowShape[In, Out] = FlowShape(in, out)
  5363. + override def createLogic(inheritedAttributes: Attributes): RestartWithBackoffLogic[FlowShape[In, Out]] = new RestartWithBackoffLogic(
  5364. "Flow", shape, minBackoff, maxBackoff, randomFactor, onlyOnFailures = false, maxRestarts) {
  5365.  
  5366. var activeOutIn: Option[(SubSourceOutlet[In], SubSinkInlet[Out])] = None
  5367.  
  5368. override protected def logSource = self.getClass
  5369.  
  5370. - override protected def startGraph() = {
  5371. + override protected def startGraph(): Unit = {
  5372. val sourceOut = createSubOutlet(in)
  5373. val sinkIn = createSubInlet(out)
  5374. Source.fromGraph(sourceOut.source).via(flowFactory()).runWith(sinkIn.sink)(subFusingMaterializer)
  5375. @@ -347,7 +348,7 @@ private final class RestartWithBackoffFlow[In, Out](
  5376. activeOutIn = Some((sourceOut, sinkIn))
  5377. }
  5378.  
  5379. - override protected def backoff() = {
  5380. + override protected def backoff(): Unit = {
  5381. setHandler(in, new InHandler {
  5382. override def onPush() = ()
  5383. })
  5384. @@ -385,7 +386,7 @@ private abstract class RestartWithBackoffLogic[S <: Shape](
  5385. onlyOnFailures: Boolean,
  5386. maxRestarts: Int) extends TimerGraphStageLogicWithLogging(shape) {
  5387. var restartCount = 0
  5388. - var resetDeadline = minBackoff.fromNow
  5389. + var resetDeadline: Deadline = minBackoff.fromNow
  5390. // This is effectively only used for flows, if either the main inlet or outlet of this stage finishes, then we
  5391. // don't want to restart the sub inlet when it finishes, we just finish normally.
  5392. var finishing = false
  5393. @@ -397,8 +398,8 @@ private abstract class RestartWithBackoffLogic[S <: Shape](
  5394. val sinkIn = new SubSinkInlet[T](s"RestartWithBackoff$name.subIn")
  5395.  
  5396. sinkIn.setHandler(new InHandler {
  5397. - override def onPush() = push(out, sinkIn.grab())
  5398. - override def onUpstreamFinish() = {
  5399. + override def onPush(): Unit = push(out, sinkIn.grab())
  5400. + override def onUpstreamFinish(): Unit = {
  5401. if (finishing || maxRestartsReached() || onlyOnFailures) {
  5402. complete(out)
  5403. } else {
  5404. @@ -406,7 +407,7 @@ private abstract class RestartWithBackoffLogic[S <: Shape](
  5405. scheduleRestartTimer()
  5406. }
  5407. }
  5408. - override def onUpstreamFailure(ex: Throwable) = {
  5409. + override def onUpstreamFailure(ex: Throwable): Unit = {
  5410. if (finishing || maxRestartsReached()) {
  5411. fail(out, ex)
  5412. } else {
  5413. @@ -417,8 +418,8 @@ private abstract class RestartWithBackoffLogic[S <: Shape](
  5414. })
  5415.  
  5416. setHandler(out, new OutHandler {
  5417. - override def onPull() = sinkIn.pull()
  5418. - override def onDownstreamFinish() = {
  5419. + override def onPull(): Unit = sinkIn.pull()
  5420. + override def onDownstreamFinish(): Unit = {
  5421. finishing = true
  5422. sinkIn.cancel()
  5423. }
  5424. @@ -431,14 +432,14 @@ private abstract class RestartWithBackoffLogic[S <: Shape](
  5425. val sourceOut = new SubSourceOutlet[T](s"RestartWithBackoff$name.subOut")
  5426.  
  5427. sourceOut.setHandler(new OutHandler {
  5428. - override def onPull() = if (isAvailable(in)) {
  5429. + override def onPull(): Unit = if (isAvailable(in)) {
  5430. sourceOut.push(grab(in))
  5431. } else {
  5432. if (!hasBeenPulled(in)) {
  5433. pull(in)
  5434. }
  5435. }
  5436. - override def onDownstreamFinish() = {
  5437. + override def onDownstreamFinish(): Unit = {
  5438. if (finishing || maxRestartsReached()) {
  5439. cancel(in)
  5440. } else {
  5441. @@ -449,14 +450,14 @@ private abstract class RestartWithBackoffLogic[S <: Shape](
  5442. })
  5443.  
  5444. setHandler(in, new InHandler {
  5445. - override def onPush() = if (sourceOut.isAvailable) {
  5446. + override def onPush(): Unit = if (sourceOut.isAvailable) {
  5447. sourceOut.push(grab(in))
  5448. }
  5449. - override def onUpstreamFinish() = {
  5450. + override def onUpstreamFinish(): Unit = {
  5451. finishing = true
  5452. sourceOut.complete()
  5453. }
  5454. - override def onUpstreamFailure(ex: Throwable) = {
  5455. + override def onUpstreamFailure(ex: Throwable): Unit = {
  5456. finishing = true
  5457. sourceOut.fail(ex)
  5458. }
  5459. @@ -465,7 +466,7 @@ private abstract class RestartWithBackoffLogic[S <: Shape](
  5460. sourceOut
  5461. }
  5462.  
  5463. - protected final def maxRestartsReached() = {
  5464. + protected final def maxRestartsReached(): Boolean = {
  5465. // Check if the last start attempt was more than the minimum backoff
  5466. if (resetDeadline.isOverdue()) {
  5467. log.debug("Last restart attempt was more than {} ago, resetting restart count", minBackoff)
  5468. @@ -475,7 +476,7 @@ private abstract class RestartWithBackoffLogic[S <: Shape](
  5469. }
  5470.  
  5471. // Set a timer to restart after the calculated delay
  5472. - protected final def scheduleRestartTimer() = {
  5473. + protected final def scheduleRestartTimer(): Unit = {
  5474. val restartDelay = BackoffSupervisor.calculateDelay(restartCount, minBackoff, maxBackoff, randomFactor)
  5475. log.debug("Restarting graph in {}", restartDelay)
  5476. scheduleOnce("RestartTimer", restartDelay)
  5477. @@ -485,11 +486,11 @@ private abstract class RestartWithBackoffLogic[S <: Shape](
  5478. }
  5479.  
  5480. // Invoked when the backoff timer ticks
  5481. - override protected def onTimer(timerKey: Any) = {
  5482. + override protected def onTimer(timerKey: Any): Unit = {
  5483. startGraph()
  5484. resetDeadline = minBackoff.fromNow
  5485. }
  5486.  
  5487. // When the stage starts, start the source
  5488. - override def preStart() = startGraph()
  5489. + override def preStart(): Unit = startGraph()
  5490. }
  5491. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Sink.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Sink.scala
  5492. index de29f07f95..0de25a9e6e 100644
  5493. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Sink.scala
  5494. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Sink.scala
  5495. @@ -331,9 +331,9 @@ object Sink {
  5496. def newOnCompleteStage(): GraphStage[FlowShape[T, NotUsed]] = {
  5497. new GraphStage[FlowShape[T, NotUsed]] {
  5498.  
  5499. - val in = Inlet[T]("in")
  5500. - val out = Outlet[NotUsed]("out")
  5501. - override val shape = FlowShape.of(in, out)
  5502. + val in: Inlet[T] = Inlet[T]("in")
  5503. + val out: Outlet[NotUsed] = Outlet[NotUsed]("out")
  5504. + override val shape: FlowShape[T, NotUsed] = FlowShape.of(in, out)
  5505.  
  5506. override def createLogic(inheritedAttributes: Attributes): GraphStageLogic =
  5507. new GraphStageLogic(shape) with InHandler with OutHandler {
  5508. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/StreamConverters.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/StreamConverters.scala
  5509. index 407a894deb..eac9662482 100644
  5510. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/StreamConverters.scala
  5511. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/StreamConverters.scala
  5512. @@ -181,7 +181,7 @@ object StreamConverters {
  5513. nextElementFuture = queue.pull()
  5514. next
  5515. }
  5516. - }, 0), false).onClose(new Runnable { def run = queue.cancel() }))
  5517. + }, 0), false).onClose(new Runnable { def run: Unit = queue.cancel() }))
  5518. .withAttributes(DefaultAttributes.asJavaStream)
  5519. }
  5520.  
  5521. diff --git a/akka-stream/src/main/scala/akka/stream/scaladsl/Tcp.scala b/akka-stream/src/main/scala/akka/stream/scaladsl/Tcp.scala
  5522. index 47f72e2d13..c6f55987c1 100644
  5523. --- a/akka-stream/src/main/scala/akka/stream/scaladsl/Tcp.scala
  5524. +++ b/akka-stream/src/main/scala/akka/stream/scaladsl/Tcp.scala
  5525. @@ -69,7 +69,7 @@ object Tcp extends ExtensionId[Tcp] with ExtensionIdProvider {
  5526.  
  5527. override def get(system: ActorSystem): Tcp = super.get(system)
  5528.  
  5529. - def lookup() = Tcp
  5530. + def lookup(): Tcp.type = Tcp
  5531.  
  5532. def createExtension(system: ExtendedActorSystem): Tcp = new Tcp(system)
  5533.  
  5534. @@ -89,7 +89,7 @@ final class Tcp(system: ExtendedActorSystem) extends akka.actor.Extension {
  5535. private val settings = ActorMaterializerSettings(system)
  5536.  
  5537. // TODO maybe this should be a new setting, like `akka.stream.tcp.bind.timeout` / `shutdown-timeout` instead?
  5538. - val bindShutdownTimeout = settings.subscriptionTimeoutSettings.timeout
  5539. + val bindShutdownTimeout: FiniteDuration = settings.subscriptionTimeoutSettings.timeout
  5540.  
  5541. /**
  5542. * Creates a [[Tcp.ServerBinding]] instance which represents a prospective TCP server binding on the given `endpoint`.
  5543. diff --git a/akka-stream/src/main/scala/akka/stream/stage/GraphStage.scala b/akka-stream/src/main/scala/akka/stream/stage/GraphStage.scala
  5544. index 3e0c26c78f..f6fbbcd04a 100644
  5545. --- a/akka-stream/src/main/scala/akka/stream/stage/GraphStage.scala
  5546. +++ b/akka-stream/src/main/scala/akka/stream/stage/GraphStage.scala
  5547. @@ -1296,7 +1296,7 @@ abstract class GraphStageLogic private[stream] (val inCount: Int, val outCount:
  5548. _sink.cancelSubstream()
  5549. }
  5550.  
  5551. - override def toString = s"SubSinkInlet($name)"
  5552. + override def toString: String = s"SubSinkInlet($name)"
  5553. }
  5554.  
  5555. /**
  5556. @@ -1389,7 +1389,7 @@ abstract class GraphStageLogic private[stream] (val inCount: Int, val outCount:
  5557. _source.failSubstream(ex)
  5558. }
  5559.  
  5560. - override def toString = s"SubSourceOutlet($name)"
  5561. + override def toString: String = s"SubSourceOutlet($name)"
  5562. }
  5563.  
  5564. }
  5565. @@ -1484,7 +1484,7 @@ abstract class TimerGraphStageLogic(_shape: Shape) extends GraphStageLogic(_shap
  5566. cancelTimer(timerKey)
  5567. val id = timerIdGen.next()
  5568. val task = interpreter.materializer.schedulePeriodically(initialDelay, interval, new Runnable {
  5569. - def run() = getTimerAsyncCallback.invoke(Scheduled(timerKey, id, repeating = true))
  5570. + def run(): Unit = getTimerAsyncCallback.invoke(Scheduled(timerKey, id, repeating = true))
  5571. })
  5572. keyToTimers(timerKey) = Timer(id, task)
  5573. }
  5574. @@ -1498,7 +1498,7 @@ abstract class TimerGraphStageLogic(_shape: Shape) extends GraphStageLogic(_shap
  5575. cancelTimer(timerKey)
  5576. val id = timerIdGen.next()
  5577. val task = interpreter.materializer.scheduleOnce(delay, new Runnable {
  5578. - def run() = getTimerAsyncCallback.invoke(Scheduled(timerKey, id, repeating = false))
  5579. + def run(): Unit = getTimerAsyncCallback.invoke(Scheduled(timerKey, id, repeating = false))
  5580. })
  5581. keyToTimers(timerKey) = Timer(id, task)
  5582. }
  5583. diff --git a/akka-stream/src/main/scala/com/typesafe/sslconfig/akka/AkkaSSLConfig.scala b/akka-stream/src/main/scala/com/typesafe/sslconfig/akka/AkkaSSLConfig.scala
  5584. index 3ad728a1a9..7a9b9bcbee 100644
  5585. --- a/akka-stream/src/main/scala/com/typesafe/sslconfig/akka/AkkaSSLConfig.scala
  5586. +++ b/akka-stream/src/main/scala/com/typesafe/sslconfig/akka/AkkaSSLConfig.scala
  5587. @@ -23,7 +23,7 @@ object AkkaSSLConfig extends ExtensionId[AkkaSSLConfig] with ExtensionIdProvider
  5588. override def get(system: ActorSystem): AkkaSSLConfig = super.get(system)
  5589. def apply()(implicit system: ActorSystem): AkkaSSLConfig = super.apply(system)
  5590.  
  5591. - override def lookup() = AkkaSSLConfig
  5592. + override def lookup(): AkkaSSLConfig.type = AkkaSSLConfig
  5593.  
  5594. override def createExtension(system: ExtendedActorSystem): AkkaSSLConfig =
  5595. new AkkaSSLConfig(system, defaultSSLConfigSettings(system))
  5596. @@ -66,9 +66,9 @@ final class AkkaSSLConfig(system: ExtendedActorSystem, val config: SSLConfigSett
  5597. def convertSettings(f: java.util.function.Function[SSLConfigSettings, SSLConfigSettings]): AkkaSSLConfig =
  5598. new AkkaSSLConfig(system, f.apply(config))
  5599.  
  5600. - val hostnameVerifier = buildHostnameVerifier(config)
  5601. + val hostnameVerifier: HostnameVerifier = buildHostnameVerifier(config)
  5602.  
  5603. - val sslEngineConfigurator = {
  5604. + val sslEngineConfigurator: DefaultSSLEngineConfigurator = {
  5605. val sslContext = if (config.default) {
  5606. log.info("ssl-config.default is true, using the JDK's default SSLContext")
  5607. validateDefaultTrustManager(config)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement