Skip to content

Commit

Permalink
Sanitize with -Xsource:3 continued
Browse files Browse the repository at this point in the history
  • Loading branch information
pbernet committed May 3, 2024
1 parent ed7c3b0 commit 40db87e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/main/scala/akkahttp/HttpFileEcho.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import spray.json.{DefaultJsonProtocol, RootJsonFormat}
import java.io.File
import java.nio.file.Paths
import java.time.LocalTime
import scala.annotation.unchecked.uncheckedStable
import scala.collection.parallel.CollectionConverters.*
import scala.concurrent.duration.*
import scala.concurrent.{Await, Future}
Expand All @@ -24,7 +25,7 @@ import scala.util.{Failure, Success}

trait JsonProtocol extends DefaultJsonProtocol with SprayJsonSupport {

@unchecked
@uncheckedStable
final case class FileHandle(fileName: String, absolutePath: String, length: Long)

object FileHandle extends ((String, String, Long) => FileHandle) {
Expand Down
5 changes: 3 additions & 2 deletions src/main/scala/akkahttp/WebsocketChatEcho.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ object WebsocketChatEcho extends App with ClientCommon {
logger.info(s"Server received: $text")
Future.successful(text)
case TextMessage.Streamed(textStream) =>
textStream.runReduce(_ + _)
.flatMap(Future.successful)
textStream.runReduce(_ + _).flatMap(Future.successful)
case bm: BinaryMessage => throw new Exception(s"Binary message: $bm cannot be handled")
case other => throw new Exception(s"Unhandled message type: $other cannot be handled")
}
.via(Flow.fromSinkAndSourceCoupled(inSink, outSource))
// Optional msg aggregation
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/akkahttp/WebsocketEcho.scala
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ object WebsocketEcho extends App with WebSocketDirectives with ClientCommon {
.repeat(s"Heartbeat response: ${LocalDateTime.now()}")
.throttle(1, 1.seconds)
.wireTap(msg => logger.info(s"Sending to client: $msg"))
.map(TextMessage.Strict)
.map(TextMessage.Strict.apply)
.watchTermination()((_, done) => done.onComplete {
case Failure(err) => logger.info(s"Heartbeat server flow failed: $err")
case _ => logger.info(s"Heartbeat server flow terminated")
Expand Down

0 comments on commit 40db87e

Please sign in to comment.