From 0a23ccd20bdd1904d5c6973993e6175751e95aaf Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 24 Feb 2023 20:38:29 +0100 Subject: [PATCH] add scala 3 support for upickle and circe --- build.sbt | 30 +++++-- .../pekkohttpavro4s/ExampleApp.scala | 2 +- .../pekkohttpcirce/CirceSupportSpec2.scala | 84 +++++++++++++++++++ .../pekkohttpcirce/CirceSupportSpec2.scala | 75 +++++++++++++++++ .../pekkohttpcirce/CirceSupportSpec.scala | 35 ++------ .../pjfanning/pekkohttpcirce/ExampleApp.scala | 4 +- .../pekkohttpjackson/ExampleApp.scala | 2 +- .../pjfanning/pekkohttpninny/ExampleApp.scala | 2 +- .../pekkohttpninny/NinnySupportSpec.scala | 2 +- .../pekkohttpplayjson/ExampleApp.scala | 2 +- .../PlayJsonSupportSpec.scala | 2 +- .../UpickleCustomizationSupport.scala | 27 +++--- .../pekkohttpupickle/UpickleSupport.scala | 2 +- .../pekkohttpupickle/ExampleApp.scala | 4 +- .../UpickleCustomizationSupportSpec.scala | 4 +- .../pekkohttpupickle/UpickleSupportSpec.scala | 2 +- .../pekkohttpziojson/ExampleApp.scala | 2 +- 17 files changed, 216 insertions(+), 65 deletions(-) create mode 100644 pekko-http-circe/src/test/scala-2/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec2.scala create mode 100644 pekko-http-circe/src/test/scala-3/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec2.scala diff --git a/build.sbt b/build.sbt index 50a2a656..189c454e 100644 --- a/build.sbt +++ b/build.sbt @@ -2,6 +2,7 @@ // Build settings // ***************************************************************************** +lazy val scalaReleaseVersion = SettingKey[Int]("scalaReleaseVersion") inThisBuild( Seq( organization := "com.github.pjfanning", @@ -41,7 +42,13 @@ inThisBuild( ), resolvers += "Apache Snapshots" at "https://repository.apache.org/content/groups/snapshots", scalafmtOnCompile := true, - dynverSeparator := "_" // the default `+` is not compatible with docker tags, + dynverSeparator := "_", // the default `+` is not compatible with docker tags + scalaReleaseVersion := { + lazy val v = scalaVersion.value + CrossVersion.partialVersion(v).map(_._1.toInt).getOrElse { + throw new RuntimeException(s"could not get Scala release version from $v") + } + } ) ) @@ -90,7 +97,7 @@ lazy val `pekko-http-argonaut` = lazy val `pekko-http-circe` = project - .settings(commonSettings) + .settings(commonSettings, withScala3) .settings( libraryDependencies ++= Seq( library.pekkoHttp, @@ -99,7 +106,18 @@ lazy val `pekko-http-circe` = library.pekkoStream % Provided, library.circeGeneric % Test, library.scalaTest % Test, - ) + ), + Test / unmanagedSourceDirectories ++= { + if (scalaReleaseVersion.value > 2) { + Seq( + (LocalRootProject / baseDirectory).value / "src" / "test" / "scala-3" + ) + } else { + Seq( + (LocalRootProject / baseDirectory).value / "src" / "test" / "scala-2", + ) + } + } ) lazy val `pekko-http-jackson` = @@ -168,7 +186,7 @@ lazy val `pekko-http-play-json` = lazy val `pekko-http-upickle` = project - .settings(commonSettings) + .settings(commonSettings, withScala3) .settings( libraryDependencies ++= Seq( library.pekkoHttp, @@ -232,8 +250,8 @@ lazy val library = val jsoniterScala = "2.17.9" val ninny = "0.7.0" val play = "2.9.2" - val scalaTest = "3.2.11" - val upickle = "1.5.0" + val scalaTest = "3.2.15" + val upickle = "1.6.0" val zioJson = "0.3.0" } // format: off diff --git a/pekko-http-avro4s/src/test/scala/com/github/pjfanning/pekkohttpavro4s/ExampleApp.scala b/pekko-http-avro4s/src/test/scala/com/github/pjfanning/pekkohttpavro4s/ExampleApp.scala index 0b619498..e3d8e6bf 100644 --- a/pekko-http-avro4s/src/test/scala/com/github/pjfanning/pekkohttpavro4s/ExampleApp.scala +++ b/pekko-http-avro4s/src/test/scala/com/github/pjfanning/pekkohttpavro4s/ExampleApp.scala @@ -38,7 +38,7 @@ object ExampleApp { final case class Foo(bar: String) def main(args: Array[String]): Unit = { - implicit val system = ActorSystem() + implicit val system: ActorSystem = ActorSystem() Http().newServerAt("127.0.0.1", 8000).bindFlow(route) diff --git a/pekko-http-circe/src/test/scala-2/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec2.scala b/pekko-http-circe/src/test/scala-2/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec2.scala new file mode 100644 index 00000000..c82dd86a --- /dev/null +++ b/pekko-http-circe/src/test/scala-2/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec2.scala @@ -0,0 +1,84 @@ +/* + * Copyright 2015 Heiko Seeberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.github.pjfanning.pekkohttpcirce + +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.marshalling.Marshal +import org.apache.pekko.http.scaladsl.model._ +import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal +import org.apache.pekko.stream.scaladsl.{ Sink, Source } +import io.circe.Encoder +import org.scalatest.concurrent.ScalaFutures +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AsyncWordSpec +import org.scalatest.{ BeforeAndAfterAll, EitherValues } + +import scala.concurrent.Await +import scala.concurrent.duration.DurationInt + +final class CirceSupportSpec2 + extends AsyncWordSpec + with Matchers + with BeforeAndAfterAll + with ScalaFutures + with EitherValues { + + import CirceSupportSpec._ + + private implicit val system: ActorSystem = ActorSystem() + + /** + * Specs common to both [[FailFastCirceSupport]] and [[ErrorAccumulatingCirceSupport]] + */ + private def commonCirceSupport(support: BaseCirceSupport) = { + import io.circe.generic.auto._ + import support._ + + "enable streamed marshalling and unmarshalling for json arrays" in { + val foos = (0 to 100).map(i => Foo(s"bar-$i")).toList + + // Don't know why, the encoder is not resolving alongside the marshaller + // this only happens if we use the implicits from BaseCirceSupport + // so, tried to create it before and guess what? it worked. + // not sure if this is a bug, but, the error is this: + // diverging implicit expansion for type io.circe.Encoder[A] + // [error] starting with lazy value encodeZoneOffset in object Encoder + implicit val e = implicitly[Encoder[Foo]] + + Marshal(Source(foos)) + .to[ResponseEntity] + .flatMap(entity => Unmarshal(entity).to[SourceOf[Foo]]) + .flatMap(_.runWith(Sink.seq)) + .map(_ shouldBe foos) + } + + } + + "FailFastCirceSupport" should { + behave like commonCirceSupport(FailFastCirceSupport) + } + + "ErrorAccumulatingCirceSupport" should { + behave like commonCirceSupport(ErrorAccumulatingCirceSupport) + + } + + override protected def afterAll(): Unit = { + Await.ready(system.terminate(), 42.seconds) + super.afterAll() + } +} diff --git a/pekko-http-circe/src/test/scala-3/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec2.scala b/pekko-http-circe/src/test/scala-3/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec2.scala new file mode 100644 index 00000000..294a9987 --- /dev/null +++ b/pekko-http-circe/src/test/scala-3/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec2.scala @@ -0,0 +1,75 @@ +/* + * Copyright 2015 Heiko Seeberger + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.github.pjfanning.pekkohttpcirce + +import org.apache.pekko.actor.ActorSystem +import org.apache.pekko.http.scaladsl.marshalling.Marshal +import org.apache.pekko.http.scaladsl.model._ +import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal +import org.apache.pekko.stream.scaladsl.{ Sink, Source } +import org.scalatest.concurrent.ScalaFutures +import org.scalatest.matchers.should.Matchers +import org.scalatest.wordspec.AsyncWordSpec +import org.scalatest.{ BeforeAndAfterAll, EitherValues } + +import scala.concurrent.Await +import scala.concurrent.duration.DurationInt + +final class CirceSupportSpec2 + extends AsyncWordSpec + with Matchers + with BeforeAndAfterAll + with ScalaFutures + with EitherValues { + + import CirceSupportSpec._ + + private implicit val system: ActorSystem = ActorSystem() + + /** + * Specs common to both [[FailFastCirceSupport]] and [[ErrorAccumulatingCirceSupport]] + */ + private def commonCirceSupport(support: BaseCirceSupport) = { + import io.circe.generic.auto._ + import support._ + + "enable streamed marshalling and unmarshalling for json arrays" in { + val foos = (0 to 100).map(i => Foo(s"bar-$i")).toList + + Marshal(Source(foos)) + .to[ResponseEntity] + .flatMap(entity => Unmarshal(entity).to[SourceOf[Foo]]) + .flatMap(_.runWith(Sink.seq)) + .map(_ shouldBe foos) + } + + } + + "FailFastCirceSupport" should { + behave like commonCirceSupport(FailFastCirceSupport) + } + + "ErrorAccumulatingCirceSupport" should { + behave like commonCirceSupport(ErrorAccumulatingCirceSupport) + + } + + override protected def afterAll(): Unit = { + Await.ready(system.terminate(), 42.seconds) + super.afterAll() + } +} diff --git a/pekko-http-circe/src/test/scala/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec.scala b/pekko-http-circe/src/test/scala/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec.scala index 23481ac5..25742833 100644 --- a/pekko-http-circe/src/test/scala/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec.scala +++ b/pekko-http-circe/src/test/scala/com/github/pjfanning/pekkohttpcirce/CirceSupportSpec.scala @@ -18,25 +18,18 @@ package com.github.pjfanning.pekkohttpcirce import org.apache.pekko.actor.ActorSystem import org.apache.pekko.http.scaladsl.marshalling.Marshal -import org.apache.pekko.http.scaladsl.model.{ - ContentTypeRange, - HttpCharsets, - HttpEntity, - MediaType, - RequestEntity, - ResponseEntity -} import org.apache.pekko.http.scaladsl.model.ContentTypes.{ `application/json`, `text/plain(UTF-8)` } -import org.apache.pekko.http.scaladsl.unmarshalling.{ Unmarshal, Unmarshaller } +import org.apache.pekko.http.scaladsl.model._ import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshaller.UnsupportedContentTypeException -import org.apache.pekko.stream.scaladsl.{ Sink, Source } +import org.apache.pekko.http.scaladsl.unmarshalling.{ Unmarshal, Unmarshaller } import cats.data.{ NonEmptyList, ValidatedNel } -import io.circe.{ DecodingFailure, Encoder, ParsingFailure, Printer } import io.circe.CursorOp.DownField -import org.scalatest.{ BeforeAndAfterAll, EitherValues } +import io.circe.{ DecodingFailure, ParsingFailure, Printer } import org.scalatest.concurrent.ScalaFutures import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AsyncWordSpec +import org.scalatest.{ BeforeAndAfterAll, EitherValues } + import scala.concurrent.Await import scala.concurrent.duration.DurationInt @@ -79,24 +72,6 @@ final class CirceSupportSpec .map(_ shouldBe foo) } - "enable streamed marshalling and unmarshalling for json arrays" in { - val foos = (0 to 100).map(i => Foo(s"bar-$i")).toList - - // Don't know why, the encoder is not resolving alongside the marshaller - // this only happens if we use the implicits from BaseCirceSupport - // so, tried to create it before and guess what? it worked. - // not sure if this is a bug, but, the error is this: - // diverging implicit expansion for type io.circe.Encoder[A] - // [error] starting with lazy value encodeZoneOffset in object Encoder - implicit val e = implicitly[Encoder[Foo]] - - Marshal(Source(foos)) - .to[ResponseEntity] - .flatMap(entity => Unmarshal(entity).to[SourceOf[Foo]]) - .flatMap(_.runWith(Sink.seq)) - .map(_ shouldBe foos) - } - "provide proper error messages for requirement errors" in { val entity = HttpEntity(`application/json`, """{ "bar": "baz" }""") Unmarshal(entity) diff --git a/pekko-http-circe/src/test/scala/com/github/pjfanning/pekkohttpcirce/ExampleApp.scala b/pekko-http-circe/src/test/scala/com/github/pjfanning/pekkohttpcirce/ExampleApp.scala index 1c220622..4f062a2a 100644 --- a/pekko-http-circe/src/test/scala/com/github/pjfanning/pekkohttpcirce/ExampleApp.scala +++ b/pekko-http-circe/src/test/scala/com/github/pjfanning/pekkohttpcirce/ExampleApp.scala @@ -31,7 +31,7 @@ object ExampleApp { private final case class Foo(bar: String) def main(args: Array[String]): Unit = { - implicit val system = ActorSystem() + implicit val system: ActorSystem = ActorSystem() Http().newServerAt("127.0.0.1", 8000).bindFlow(route) @@ -54,7 +54,7 @@ object ExampleApp { } } ~ pathPrefix("stream") { post { - entity(as[SourceOf[Foo]]) { fooSource: SourceOf[Foo] => + entity(as[SourceOf[Foo]]) { (fooSource: SourceOf[Foo]) => import sys._ Marshal(Source.single(Foo("a"))).to[RequestEntity] diff --git a/pekko-http-jackson/src/test/scala/com/github/pjfanning/pekkohttpjackson/ExampleApp.scala b/pekko-http-jackson/src/test/scala/com/github/pjfanning/pekkohttpjackson/ExampleApp.scala index 5859a90d..91edbd3a 100644 --- a/pekko-http-jackson/src/test/scala/com/github/pjfanning/pekkohttpjackson/ExampleApp.scala +++ b/pekko-http-jackson/src/test/scala/com/github/pjfanning/pekkohttpjackson/ExampleApp.scala @@ -31,7 +31,7 @@ object ExampleApp { final case class Foo(bar: String) def main(args: Array[String]): Unit = { - implicit val system = ActorSystem() + implicit val system: ActorSystem = ActorSystem() // provide an implicit ObjectMapper if you want serialization/deserialization to use it // instead of a default ObjectMapper configured only with DefaultScalaModule provided diff --git a/pekko-http-ninny/src/test/scala/com/github/pjfanning/pekkohttpninny/ExampleApp.scala b/pekko-http-ninny/src/test/scala/com/github/pjfanning/pekkohttpninny/ExampleApp.scala index 66466f12..e01b34f4 100644 --- a/pekko-http-ninny/src/test/scala/com/github/pjfanning/pekkohttpninny/ExampleApp.scala +++ b/pekko-http-ninny/src/test/scala/com/github/pjfanning/pekkohttpninny/ExampleApp.scala @@ -32,7 +32,7 @@ object ExampleApp { private final case class Foo(bar: String) def main(args: Array[String]): Unit = { - implicit val system = ActorSystem() + implicit val system: ActorSystem = ActorSystem() Http().newServerAt("127.0.0.1", 8000).bindFlow(route) diff --git a/pekko-http-ninny/src/test/scala/com/github/pjfanning/pekkohttpninny/NinnySupportSpec.scala b/pekko-http-ninny/src/test/scala/com/github/pjfanning/pekkohttpninny/NinnySupportSpec.scala index 3b8b5022..cc4aa976 100644 --- a/pekko-http-ninny/src/test/scala/com/github/pjfanning/pekkohttpninny/NinnySupportSpec.scala +++ b/pekko-http-ninny/src/test/scala/com/github/pjfanning/pekkohttpninny/NinnySupportSpec.scala @@ -42,7 +42,7 @@ final class NinnySupportSpec extends AsyncWordSpec with Matchers with BeforeAndA import NinnySupportSpec._ import io.github.kag0.ninny.Auto._ - private implicit val system = ActorSystem() + private implicit val system: ActorSystem = ActorSystem() "NinnySupport" should { "enable marshalling and unmarshalling objects for which `ToJson` and `FromSomeJson` exist" in { diff --git a/pekko-http-play-json/src/test/scala/com/github/pjfanning/pekkohttpplayjson/ExampleApp.scala b/pekko-http-play-json/src/test/scala/com/github/pjfanning/pekkohttpplayjson/ExampleApp.scala index eddd5bf2..665bf42b 100644 --- a/pekko-http-play-json/src/test/scala/com/github/pjfanning/pekkohttpplayjson/ExampleApp.scala +++ b/pekko-http-play-json/src/test/scala/com/github/pjfanning/pekkohttpplayjson/ExampleApp.scala @@ -35,7 +35,7 @@ object ExampleApp { final case class Foo(bar: String) def main(args: Array[String]): Unit = { - implicit val system = ActorSystem() + implicit val system: ActorSystem = ActorSystem() Http().newServerAt("127.0.0.1", 8000).bindFlow(route) diff --git a/pekko-http-play-json/src/test/scala/com/github/pjfanning/pekkohttpplayjson/PlayJsonSupportSpec.scala b/pekko-http-play-json/src/test/scala/com/github/pjfanning/pekkohttpplayjson/PlayJsonSupportSpec.scala index 49be4f99..1bea92a0 100644 --- a/pekko-http-play-json/src/test/scala/com/github/pjfanning/pekkohttpplayjson/PlayJsonSupportSpec.scala +++ b/pekko-http-play-json/src/test/scala/com/github/pjfanning/pekkohttpplayjson/PlayJsonSupportSpec.scala @@ -45,7 +45,7 @@ final class PlayJsonSupportSpec extends AsyncWordSpec with Matchers with BeforeA import PlayJsonSupport._ import PlayJsonSupportSpec._ - private implicit val system = ActorSystem() + private implicit val system: ActorSystem = ActorSystem() "PlayJsonSupport" should { "enable marshalling and unmarshalling objects for which `Writes` and `Reads` exist" in { diff --git a/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupport.scala b/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupport.scala index c3974907..8ed84bee 100644 --- a/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupport.scala +++ b/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupport.scala @@ -16,6 +16,7 @@ package com.github.pjfanning.pekkohttpupickle +import com.github.pjfanning.pekkohttpupickle.UpickleCustomizationSupport._ import org.apache.pekko.http.javadsl.common.JsonEntityStreamingSupport import org.apache.pekko.http.scaladsl.common.EntityStreamingSupport import org.apache.pekko.http.scaladsl.marshalling.{ Marshaller, Marshalling, ToEntityMarshaller } @@ -34,7 +35,7 @@ import org.apache.pekko.http.scaladsl.unmarshalling.{ import org.apache.pekko.http.scaladsl.util.FastFuture import org.apache.pekko.stream.scaladsl.{ Flow, Source } import org.apache.pekko.util.ByteString -import com.github.pjfanning.pekkohttpupickle.UpickleCustomizationSupport._ + import scala.collection.immutable.Seq import scala.concurrent.Future import scala.util.Try @@ -67,9 +68,7 @@ trait UpickleCustomizationSupport { type Api <: upickle.Api - def api: Api - - private lazy val apiInstance: Api = api + val api: Api def unmarshallerContentTypes: Seq[ContentTypeRange] = mediaTypes.map(ContentTypeRange.apply) @@ -94,11 +93,11 @@ trait UpickleCustomizationSupport { } private def jsonSource[A](entitySource: SourceOf[A])(implicit - writes: apiInstance.Writer[A], + writes: api.Writer[A], support: JsonEntityStreamingSupport ): SourceOf[ByteString] = entitySource - .map(apiInstance.write(_)) + .map(api.write(_)) .map(ByteString(_)) .via(support.framingRenderer) @@ -110,8 +109,8 @@ trait UpickleCustomizationSupport { * @return * unmarshaller for any `A` value */ - implicit def fromByteStringUnmarshaller[A: apiInstance.Reader]: Unmarshaller[ByteString, A] = - Unmarshaller(_ => bs => Future.fromTry(Try(apiInstance.read(bs.toArray)))) + implicit def fromByteStringUnmarshaller[A: api.Reader]: Unmarshaller[ByteString, A] = + Unmarshaller(_ => bs => Future.fromTry(Try(api.read(bs.toArray)))) /** * HTTP entity => `A` @@ -121,8 +120,8 @@ trait UpickleCustomizationSupport { * @return * unmarshaller for `A` */ - implicit def unmarshaller[A: apiInstance.Reader]: FromEntityUnmarshaller[A] = - jsonStringUnmarshaller(this).map(apiInstance.read(_)) + implicit def unmarshaller[A: api.Reader]: FromEntityUnmarshaller[A] = + jsonStringUnmarshaller(this).map(api.read(_)) /** * `A` => HTTP entity @@ -132,8 +131,8 @@ trait UpickleCustomizationSupport { * @return * marshaller for any `A` value */ - implicit def marshaller[A: apiInstance.Writer]: ToEntityMarshaller[A] = - jsonStringMarshaller(this).compose(apiInstance.write(_)) + implicit def marshaller[A: api.Writer]: ToEntityMarshaller[A] = + jsonStringMarshaller(this).compose(api.write(_)) /** * HTTP entity => `Source[A, _]` @@ -143,7 +142,7 @@ trait UpickleCustomizationSupport { * @return * unmarshaller for `Source[A, _]` */ - implicit def sourceUnmarshaller[A: apiInstance.Reader](implicit + implicit def sourceUnmarshaller[A: api.Reader](implicit support: JsonEntityStreamingSupport = EntityStreamingSupport.json() ): FromEntityUnmarshaller[SourceOf[A]] = Unmarshaller @@ -174,7 +173,7 @@ trait UpickleCustomizationSupport { * marshaller for any `SourceOf[A]` value */ implicit def sourceMarshaller[A](implicit - writes: apiInstance.Writer[A], + writes: api.Writer[A], support: JsonEntityStreamingSupport = EntityStreamingSupport.json() ): ToEntityMarshaller[SourceOf[A]] = jsonSourceStringMarshaller(this).compose(jsonSource[A]) diff --git a/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleSupport.scala b/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleSupport.scala index 8e2ac58e..544f057e 100644 --- a/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleSupport.scala +++ b/pekko-http-upickle/src/main/scala/com/github/pjfanning/pekkohttpupickle/UpickleSupport.scala @@ -28,5 +28,5 @@ trait UpickleSupport extends UpickleCustomizationSupport { override type Api = upickle.default.type - override def api: Api = upickle.default + override val api: Api = upickle.default } diff --git a/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/ExampleApp.scala b/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/ExampleApp.scala index 1b088652..c5e1b8d1 100644 --- a/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/ExampleApp.scala +++ b/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/ExampleApp.scala @@ -36,7 +36,7 @@ object ExampleApp { final case class Foo(bar: String) def main(args: Array[String]): Unit = { - implicit val system = ActorSystem() + implicit val system: ActorSystem = ActorSystem() Http().newServerAt("127.0.0.1", 8000).bindFlow(route) @@ -58,7 +58,7 @@ object ExampleApp { } } ~ pathPrefix("stream") { post { - entity(as[SourceOf[Foo]]) { fooSource: SourceOf[Foo] => + entity(as[SourceOf[Foo]]) { (fooSource: SourceOf[Foo]) => complete(fooSource.throttle(1, 2.seconds)) } } ~ get { diff --git a/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupportSpec.scala b/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupportSpec.scala index 6f4e682c..f2228e7c 100644 --- a/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupportSpec.scala +++ b/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/UpickleCustomizationSupportSpec.scala @@ -33,7 +33,7 @@ final class UpickleCustomizationSupportSpec with Matchers with BeforeAndAfterAll { - private implicit val system = ActorSystem() + private implicit val system: ActorSystem = ActorSystem() object FooApi extends AttributeTagged { override implicit val IntWriter: FooApi.Writer[Int] = new Writer[Int] { @@ -42,7 +42,7 @@ final class UpickleCustomizationSupportSpec } object UpickleFoo extends UpickleCustomizationSupport { override type Api = FooApi.type - override def api: FooApi.type = FooApi + override val api: FooApi.type = FooApi } import UpickleFoo._ diff --git a/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/UpickleSupportSpec.scala b/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/UpickleSupportSpec.scala index dd5cd3ba..3516e298 100644 --- a/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/UpickleSupportSpec.scala +++ b/pekko-http-upickle/src/test/scala/com/github/pjfanning/pekkohttpupickle/UpickleSupportSpec.scala @@ -46,7 +46,7 @@ final class UpickleSupportSpec extends AsyncWordSpec with Matchers with BeforeAn import UpickleSupport._ import UpickleSupportSpec._ - private implicit val system = ActorSystem() + private implicit val system: ActorSystem = ActorSystem() "UpickleSupport" should { "enable marshalling and unmarshalling of case classes" in { diff --git a/pekko-http-zio-json/src/test/scala/com/github/pjfanning/pekkohttpziojson/ExampleApp.scala b/pekko-http-zio-json/src/test/scala/com/github/pjfanning/pekkohttpziojson/ExampleApp.scala index 4e28c1db..7b763945 100644 --- a/pekko-http-zio-json/src/test/scala/com/github/pjfanning/pekkohttpziojson/ExampleApp.scala +++ b/pekko-http-zio-json/src/test/scala/com/github/pjfanning/pekkohttpziojson/ExampleApp.scala @@ -37,7 +37,7 @@ object ExampleApp { private implicit val rt: zio.Runtime[Any] = zio.Runtime.default def main(args: Array[String]): Unit = { - implicit val system = ActorSystem() + implicit val system: ActorSystem = ActorSystem() Http().newServerAt("127.0.0.1", 8000).bindFlow(route)