diff --git a/.scala-steward.conf b/.scala-steward.conf index 243c973d7..5f1fd5ee9 100644 --- a/.scala-steward.conf +++ b/.scala-steward.conf @@ -32,8 +32,6 @@ updates.pin = [ { groupId = "org.eclipse.jgit", artifactId = "org.eclipse.jgit", version = "5." }, # https://github.com/akka/akka-grpc/issues/1661 - { groupId = "org.slf4j", artifactId = "slf4j-api", version = "1." } - # logback 1.3 and 1.4 would bump sfl4j to 2.0.0 - # http://mailman.qos.ch/pipermail/announce/2022/000177.html - { groupId = "ch.qos.logback", artifactId = "logback-classic", version = "1.2." } + { groupId = "org.slf4j", artifactId = "slf4j-api", version = "2.0." } + { groupId = "ch.qos.logback", artifactId = "logback-classic", version = "1.5." } ] diff --git a/benchmarks/src/main/scala/akka/grpc/BenchRunner.scala b/benchmarks/src/main/scala/akka/grpc/BenchRunner.scala index d74894d71..09e9ab499 100644 --- a/benchmarks/src/main/scala/akka/grpc/BenchRunner.scala +++ b/benchmarks/src/main/scala/akka/grpc/BenchRunner.scala @@ -11,7 +11,7 @@ import org.openjdk.jmh.runner.options.CommandLineOptions object BenchRunner { def main(args: Array[String]): Unit = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ // @formatter:off val args2 = args.toList.flatMap { diff --git a/build.sbt b/build.sbt index 1a6b8787d..9343d2245 100644 --- a/build.sbt +++ b/build.sbt @@ -30,10 +30,10 @@ lazy val codegen = Project(id = akkaGrpcCodegenId, base = file("codegen")) }, buildInfoKeys ++= Seq[BuildInfoKey](organization, name, version, scalaVersion, sbtVersion), buildInfoKeys += "runtimeArtifactName" -> akkaGrpcRuntimeName, - buildInfoKeys += "akkaVersion" → Dependencies.Versions.akka, - buildInfoKeys += "akkaHttpVersion" → Dependencies.Versions.akkaHttp, - buildInfoKeys += "grpcVersion" → Dependencies.Versions.grpc, - buildInfoKeys += "googleProtobufVersion" → Dependencies.Versions.googleProtobuf, + buildInfoKeys += "akkaVersion" -> Dependencies.Versions.akka, + buildInfoKeys += "akkaHttpVersion" -> Dependencies.Versions.akkaHttp, + buildInfoKeys += "grpcVersion" -> Dependencies.Versions.grpc, + buildInfoKeys += "googleProtobufVersion" -> Dependencies.Versions.googleProtobuf, buildInfoPackage := "akka.grpc.gen", (Compile / assembly / artifact) := { val art = (Compile / assembly / artifact).value diff --git a/codegen/src/main/scala/akka/grpc/gen/javadsl/JavaCodeGenerator.scala b/codegen/src/main/scala/akka/grpc/gen/javadsl/JavaCodeGenerator.scala index a262228ef..efb76938c 100644 --- a/codegen/src/main/scala/akka/grpc/gen/javadsl/JavaCodeGenerator.scala +++ b/codegen/src/main/scala/akka/grpc/gen/javadsl/JavaCodeGenerator.scala @@ -10,7 +10,7 @@ import protocbridge.Artifact import templates.JavaCommon.txt.ApiInterface import scala.annotation.nowarn -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.collection.immutable import protocgen.CodeGenRequest diff --git a/codegen/src/main/scala/akka/grpc/gen/javadsl/Service.scala b/codegen/src/main/scala/akka/grpc/gen/javadsl/Service.scala index 4857f7c30..8d505af80 100644 --- a/codegen/src/main/scala/akka/grpc/gen/javadsl/Service.scala +++ b/codegen/src/main/scala/akka/grpc/gen/javadsl/Service.scala @@ -9,7 +9,7 @@ import protocgen.CodeGenRequest import scalapb.compiler.{ DescriptorImplicits, GeneratorParams } import scala.annotation.tailrec -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.collection.immutable final case class Service( diff --git a/codegen/src/main/scala/akka/grpc/gen/scaladsl/ScalaCodeGenerator.scala b/codegen/src/main/scala/akka/grpc/gen/scaladsl/ScalaCodeGenerator.scala index 73b2719ef..3d56afcfe 100644 --- a/codegen/src/main/scala/akka/grpc/gen/scaladsl/ScalaCodeGenerator.scala +++ b/codegen/src/main/scala/akka/grpc/gen/scaladsl/ScalaCodeGenerator.scala @@ -5,7 +5,7 @@ package akka.grpc.gen.scaladsl import scala.annotation.nowarn -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.collection.immutable import akka.grpc.gen.{ BuildInfo, CodeGenerator, Logger } import com.google.protobuf.compiler.PluginProtos.{ CodeGeneratorRequest, CodeGeneratorResponse } diff --git a/codegen/src/main/scala/akka/grpc/gen/scaladsl/Service.scala b/codegen/src/main/scala/akka/grpc/gen/scaladsl/Service.scala index ad15cf296..4bb0bc197 100644 --- a/codegen/src/main/scala/akka/grpc/gen/scaladsl/Service.scala +++ b/codegen/src/main/scala/akka/grpc/gen/scaladsl/Service.scala @@ -5,7 +5,7 @@ package akka.grpc.gen.scaladsl import scala.collection.immutable -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import com.google.protobuf.Descriptors._ import protocgen.CodeGenRequest import scalapb.compiler.{ DescriptorImplicits, GeneratorParams } diff --git a/maven-plugin/src/main/scala/akka/grpc/maven/AbstractGenerateMojo.scala b/maven-plugin/src/main/scala/akka/grpc/maven/AbstractGenerateMojo.scala index a8579de92..a927ec67c 100644 --- a/maven-plugin/src/main/scala/akka/grpc/maven/AbstractGenerateMojo.scala +++ b/maven-plugin/src/main/scala/akka/grpc/maven/AbstractGenerateMojo.scala @@ -77,7 +77,7 @@ object AbstractGenerateMojo { * e.g. { "flatPackage": "true", "serverPowerApis": "false" } -> ["flat_package"] */ def parseGeneratorSettings(generatorSettings: java.util.Map[String, String]): Seq[String] = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ generatorSettings.asScala.filter(_._2.toLowerCase() != "false").keys.toSeq.map { params => "[A-Z]".r.replaceAllIn(params, (s => s"_${s.group(0).toLowerCase()}")) } @@ -110,7 +110,7 @@ abstract class AbstractGenerateMojo @Inject() (buildContext: BuildContext) exten @BeanProperty var generatePlayServer: Boolean = _ - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ @BeanProperty var generatorSettings: java.util.Map[String, String] = _ diff --git a/maven-plugin/src/test/scala/akka/grpc/maven/ProtocSpec.scala b/maven-plugin/src/test/scala/akka/grpc/maven/ProtocSpec.scala index 661ba6717..ac89acb59 100644 --- a/maven-plugin/src/test/scala/akka/grpc/maven/ProtocSpec.scala +++ b/maven-plugin/src/test/scala/akka/grpc/maven/ProtocSpec.scala @@ -22,7 +22,7 @@ class ProtocSpec extends AnyWordSpec with Matchers { } } - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ "Parsing generator settings" should { "filter out the false values" in { diff --git a/native-image-tests/grpc-scala/build.sbt b/native-image-tests/grpc-scala/build.sbt index 53ebfed04..c30396c08 100644 --- a/native-image-tests/grpc-scala/build.sbt +++ b/native-image-tests/grpc-scala/build.sbt @@ -4,7 +4,7 @@ version := "1.0" scalaVersion := "2.13.14" -lazy val akkaVersion = sys.props.getOrElse("akka.version", "2.9.3") +lazy val akkaVersion = sys.props.getOrElse("akka.version", "2.10.0-M1") lazy val akkaGrpcVersion = sys.props.getOrElse("akka.grpc.version", "2.4.0") enablePlugins(AkkaGrpcPlugin) diff --git a/plugin-tester-java/build.gradle b/plugin-tester-java/build.gradle index 650966366..15d890503 100644 --- a/plugin-tester-java/build.gradle +++ b/plugin-tester-java/build.gradle @@ -37,7 +37,7 @@ repositories { def scalaVersion = org.gradle.util.VersionNumber.parse(System.getenv("TRAVIS_SCALA_VERSION") ?: "2.13") def scalaBinaryVersion = "${scalaVersion.major}.${scalaVersion.minor}" -def akkaVersion = "2.9.3" +def akkaVersion = "2.10.0-M1" tasks.named("processResources") { duplicatesStrategy = DuplicatesStrategy.EXCLUDE diff --git a/plugin-tester-java/pom.xml b/plugin-tester-java/pom.xml index c2eedbbad..ca64aa1e3 100644 --- a/plugin-tester-java/pom.xml +++ b/plugin-tester-java/pom.xml @@ -15,7 +15,7 @@ 3.1.2 3.0.0 1.1.0 - 2.9.3 + 2.10.0-M1 1.63.2 UTF-8 3.3.0 diff --git a/plugin-tester-scala/build.gradle b/plugin-tester-scala/build.gradle index d103df94e..403df4c52 100644 --- a/plugin-tester-scala/build.gradle +++ b/plugin-tester-scala/build.gradle @@ -33,7 +33,7 @@ repositories { def scalaVersion = org.gradle.util.VersionNumber.parse(System.getenv("TRAVIS_SCALA_VERSION") ?: "2.13") def scalaBinaryVersion = "${scalaVersion.major}.${scalaVersion.minor}" -def akkaVersion = "2.9.3" +def akkaVersion = "2.10.0-M1" def protoGoogleCommonVersion = "2.22.0" tasks.named("processResources") { diff --git a/plugin-tester-scala/pom.xml b/plugin-tester-scala/pom.xml index bc1b1532a..b4c4708f6 100644 --- a/plugin-tester-scala/pom.xml +++ b/plugin-tester-scala/pom.xml @@ -12,7 +12,7 @@ 11 - 2.9.3 + 2.10.0-M1 0.4.2 1.63.2 UTF-8 diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 4b020f059..229a9fb01 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -17,9 +17,9 @@ object Dependencies { // We don't force Akka updates because downstream projects can upgrade // themselves. For more information see // https://doc.akka.io//docs/akka/current/project/downstream-upgrade-strategy.html - val akka = "2.9.3" - val akkaBinary = "2.9" - val akkaHttp = "10.6.3" + val akka = "2.10.0-M1" + val akkaBinary = "2.11" + val akkaHttp = "10.7.0-M1" val akkaHttpBinary = "10.6" val grpc = "1.63.2" // checked synced by VersionSyncCheckPlugin @@ -59,7 +59,7 @@ object Dependencies { .exclude("io.grpc", "grpc-alts") .exclude("io.grpc", "grpc-xds") - val slf4jApi = "org.slf4j" % "slf4j-api" % "1.7.36" + val slf4jApi = "org.slf4j" % "slf4j-api" % "2.0.16" val mavenPluginApi = "org.apache.maven" % "maven-plugin-api" % Versions.maven // Apache v2 val mavenCore = "org.apache.maven" % "maven-core" % Versions.maven // Apache v2 val protocJar = "com.github.os72" % "protoc-jar" % "3.11.4" @@ -113,6 +113,7 @@ object Dependencies { Compile.akkaStream, Compile.akkaHttpCore, Compile.akkaHttp, + Compile.akkaPki, Compile.akkaDiscovery, Test.akkaTestkit, Test.akkaStreamTestkit, diff --git a/project/VersionSyncCheckPlugin.scala b/project/VersionSyncCheckPlugin.scala index 48720d566..6fa9b121c 100644 --- a/project/VersionSyncCheckPlugin.scala +++ b/project/VersionSyncCheckPlugin.scala @@ -2,7 +2,7 @@ package akka.grpc import java.nio.file.{ Files, Path, Paths } -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.sys.process._ import scala.util.matching.UnanchoredRegex diff --git a/runtime/src/main/scala/akka/grpc/GrpcChannel.scala b/runtime/src/main/scala/akka/grpc/GrpcChannel.scala index 1799a32dd..e7d7e503c 100644 --- a/runtime/src/main/scala/akka/grpc/GrpcChannel.scala +++ b/runtime/src/main/scala/akka/grpc/GrpcChannel.scala @@ -6,8 +6,8 @@ package akka.grpc import java.util.concurrent.CompletionStage -import scala.compat.java8.FutureConverters._ import scala.concurrent.Future +import scala.jdk.FutureConverters._ import akka.Done import akka.actor.ClassicActorSystemProvider @@ -25,14 +25,14 @@ final class GrpcChannel private ( * Java API: Initiates a shutdown in which preexisting and new calls are cancelled. */ def closeCS(): CompletionStage[Done] = - close().toJava + close().asJava /** * Java API: Returns a CompletionStage that completes successfully when channel is shut down via close(), * or exceptionally if connection cannot be established or reestablished after maxConnectionAttempts. */ def closedCS(): CompletionStage[Done] = - closed().toJava + closed().asJava /** * Scala API: Initiates a shutdown in which preexisting and new calls are cancelled. diff --git a/runtime/src/main/scala/akka/grpc/GrpcClientSettings.scala b/runtime/src/main/scala/akka/grpc/GrpcClientSettings.scala index dda122fd7..3454b8c34 100644 --- a/runtime/src/main/scala/akka/grpc/GrpcClientSettings.scala +++ b/runtime/src/main/scala/akka/grpc/GrpcClientSettings.scala @@ -10,15 +10,16 @@ import akka.discovery.{ Discovery, ServiceDiscovery } import akka.discovery.ServiceDiscovery.{ Resolved, ResolvedTarget } import akka.grpc.internal.HardcodedServiceDiscovery import akka.util.Helpers -import akka.util.JavaDurationConverters._ import com.typesafe.config.{ Config, ConfigValueFactory } import io.grpc.CallCredentials import io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder import io.grpc.netty.shaded.io.netty.handler.ssl.SslProvider import javax.net.ssl.{ SSLContext, TrustManager } + import scala.collection.immutable import scala.concurrent.duration.{ Duration, _ } +import scala.jdk.DurationConverters._ object GrpcClientSettings { @@ -77,7 +78,7 @@ object GrpcClientSettings { implicit actorSystem: ClassicActorSystemProvider): GrpcClientSettings = { val clientConfiguration: Config = actorSystem.classicSystem.settings.config.getConfig("akka.grpc.client").getConfig("\"*\"") - val resolveTimeout = clientConfiguration.getDuration("service-discovery.resolve-timeout").asScala + val resolveTimeout = clientConfiguration.getDuration("service-discovery.resolve-timeout").toScala val discovery = Discovery.get(actorSystem).discovery withConfigDefaults(serviceName, discovery, -1, resolveTimeout, clientConfiguration) } @@ -94,7 +95,7 @@ object GrpcClientSettings { implicit actorSystem: ClassicActorSystemProvider): GrpcClientSettings = { val clientConfiguration: Config = actorSystem.classicSystem.settings.config.getConfig("akka.grpc.client").getConfig("\"*\"") - val resolveTimeout = clientConfiguration.getDuration("service-discovery.resolve-timeout").asScala + val resolveTimeout = clientConfiguration.getDuration("service-discovery.resolve-timeout").toScala withConfigDefaults(serviceName, discovery, -1, resolveTimeout, clientConfiguration) } @@ -105,7 +106,7 @@ object GrpcClientSettings { val serviceDiscoveryMechanism = clientConfiguration.getString("service-discovery.mechanism") var serviceName = clientConfiguration.getString("service-discovery.service-name") val port = clientConfiguration.getInt("port") - val resolveTimeout = clientConfiguration.getDuration("service-discovery.resolve-timeout").asScala + val resolveTimeout = clientConfiguration.getDuration("service-discovery.resolve-timeout").toScala val sd = serviceDiscoveryMechanism match { case "static" | "grpc-dns" => val host = clientConfiguration.getString("host") @@ -174,7 +175,7 @@ object GrpcClientSettings { private def getOptionalDuration(config: Config, path: String): Option[FiniteDuration] = Helpers.toRootLowerCase(config.getString(path)) match { case "off" => None - case _ => Some(config.getDuration(path).asScala) + case _ => Some(config.getDuration(path).toScala) } private def getPotentiallyInfiniteDuration(underlying: Config, path: String): Duration = @@ -337,7 +338,7 @@ final class GrpcClientSettings private ( */ @ApiMayChange def withDiscoveryRefreshInterval(refreshInterval: java.time.Duration): GrpcClientSettings = - copy(discoveryRefreshInterval = Some(refreshInterval.asScala)) + copy(discoveryRefreshInterval = Some(refreshInterval.toScala)) /** * Request that the client try to connect the service immediately when the client is created diff --git a/runtime/src/main/scala/akka/grpc/SSLContextUtils.scala b/runtime/src/main/scala/akka/grpc/SSLContextUtils.scala index 890af2415..dc9dac8cb 100644 --- a/runtime/src/main/scala/akka/grpc/SSLContextUtils.scala +++ b/runtime/src/main/scala/akka/grpc/SSLContextUtils.scala @@ -13,7 +13,7 @@ import javax.net.ssl.{ TrustManager, TrustManagerFactory } object SSLContextUtils { def trustManagerFromStream(certStream: InputStream): TrustManager = { try { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ val cf = CertificateFactory.getInstance("X.509") val bis = new BufferedInputStream(certStream) diff --git a/runtime/src/main/scala/akka/grpc/internal/AkkaDiscoveryNameResolver.scala b/runtime/src/main/scala/akka/grpc/internal/AkkaDiscoveryNameResolver.scala index dac3f9f74..0346befff 100644 --- a/runtime/src/main/scala/akka/grpc/internal/AkkaDiscoveryNameResolver.scala +++ b/runtime/src/main/scala/akka/grpc/internal/AkkaDiscoveryNameResolver.scala @@ -103,7 +103,7 @@ private[akka] final class AkkaDiscoveryNameResolver( @throws[UnknownHostException] private def addresses(addresses: Seq[ResolvedTarget]) = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ addresses .map(target => { val port = target.port.getOrElse(defaultPort) diff --git a/runtime/src/main/scala/akka/grpc/internal/AkkaHttpClientUtils.scala b/runtime/src/main/scala/akka/grpc/internal/AkkaHttpClientUtils.scala index 30485231f..89eea6bc4 100644 --- a/runtime/src/main/scala/akka/grpc/internal/AkkaHttpClientUtils.scala +++ b/runtime/src/main/scala/akka/grpc/internal/AkkaHttpClientUtils.scala @@ -43,7 +43,7 @@ import javax.net.ssl.KeyManager import javax.net.ssl.SSLContext import javax.net.ssl.TrustManager import scala.collection.immutable -import scala.compat.java8.FutureConverters.FutureOps +import scala.jdk.FutureConverters.FutureOps import scala.concurrent.duration._ import scala.concurrent.ExecutionContext import scala.concurrent.Future @@ -305,7 +305,7 @@ object AkkaHttpClientUtils { override def getTrailers(): CompletionStage[akka.grpc.javadsl.Metadata] = trailerPromise.future .map[akka.grpc.javadsl.Metadata](h => new JavaMetadataImpl(new HeaderMetadataImpl(h))) - .toJava + .asJava })) case Failure(e) => Source.failed[O](e).mapMaterializedValue(_ => Future.failed(e)) diff --git a/runtime/src/main/scala/akka/grpc/internal/AkkaNettyGrpcClientGraphStage.scala b/runtime/src/main/scala/akka/grpc/internal/AkkaNettyGrpcClientGraphStage.scala index e9d8f4384..039aa1437 100644 --- a/runtime/src/main/scala/akka/grpc/internal/AkkaNettyGrpcClientGraphStage.scala +++ b/runtime/src/main/scala/akka/grpc/internal/AkkaNettyGrpcClientGraphStage.scala @@ -5,15 +5,15 @@ package akka.grpc.internal import akka.annotation.InternalApi -import akka.dispatch.ExecutionContexts import akka.grpc.GrpcResponseMetadata import akka.stream import akka.stream.{ Attributes => _, _ } import akka.stream.stage._ import io.grpc._ +import scala.concurrent.ExecutionContext import scala.concurrent.{ Future, Promise } -import scala.compat.java8.FutureConverters._ +import scala.jdk.FutureConverters._ @InternalApi private object AkkaNettyGrpcClientGraphStage { @@ -92,10 +92,10 @@ private final class AkkaNettyGrpcClientGraphStage[I, O]( def getHeaders() = jMetadata private lazy val sTrailers = - trailerPromise.future.map(MetadataImpl.scalaMetadataFromGoogleGrpcMetadata)(ExecutionContexts.parasitic) + trailerPromise.future.map(MetadataImpl.scalaMetadataFromGoogleGrpcMetadata)(ExecutionContext.parasitic) private lazy val jTrailers = trailerPromise.future - .map(MetadataImpl.javaMetadataFromGoogleGrpcMetadata)(ExecutionContexts.parasitic) - .toJava + .map(MetadataImpl.javaMetadataFromGoogleGrpcMetadata)(ExecutionContext.parasitic) + .asJava def trailers = sTrailers def getTrailers() = jTrailers }) diff --git a/runtime/src/main/scala/akka/grpc/internal/MetadataImpl.scala b/runtime/src/main/scala/akka/grpc/internal/MetadataImpl.scala index 0514c82c5..962a57583 100644 --- a/runtime/src/main/scala/akka/grpc/internal/MetadataImpl.scala +++ b/runtime/src/main/scala/akka/grpc/internal/MetadataImpl.scala @@ -5,9 +5,9 @@ package akka.grpc.internal import java.util.{ Locale, Optional, List => jList, Map => jMap } -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.collection.immutable -import scala.compat.java8.OptionConverters._ +import scala.jdk.OptionConverters._ import akka.annotation.InternalApi import akka.http.scaladsl.model.{ AttributeKey, HttpHeader, HttpMessage } import akka.http.javadsl.{ model => jm } @@ -224,10 +224,10 @@ class HttpMessageMetadataImpl(message: HttpMessage) extends HeaderMetadataImpl(m @InternalApi class JavaMetadataImpl(val delegate: Metadata) extends javadsl.Metadata with javadsl.MetadataStatus { override def getText(key: String): Optional[String] = - delegate.getText(key).asJava + delegate.getText(key).toJava override def getBinary(key: String): Optional[ByteString] = - delegate.getBinary(key).asJava + delegate.getBinary(key).toJava override def asMap(): jMap[String, jList[javadsl.MetadataEntry]] = { // This method is also affected by incompatible changes between scala 2.12 and 2.13. (See comment in @@ -244,7 +244,7 @@ class JavaMetadataImpl(val delegate: Metadata) extends javadsl.Metadata with jav delegate override def getAttribute[T](key: jm.AttributeKey[T]): Optional[T] = - delegate.rawHttpMessage.flatMap(_.attribute(key)).asJava + delegate.rawHttpMessage.flatMap(_.attribute(key)).toJava override def toString: String = delegate.toString diff --git a/runtime/src/main/scala/akka/grpc/internal/RequestBuilderImpl.scala b/runtime/src/main/scala/akka/grpc/internal/RequestBuilderImpl.scala index e1fcf7b9a..b0d215978 100644 --- a/runtime/src/main/scala/akka/grpc/internal/RequestBuilderImpl.scala +++ b/runtime/src/main/scala/akka/grpc/internal/RequestBuilderImpl.scala @@ -8,7 +8,6 @@ import java.time.{ Duration => JDuration } import java.util.concurrent.{ CompletionStage, TimeUnit } import akka.NotUsed import akka.annotation.{ InternalApi, InternalStableApi } -import akka.dispatch.ExecutionContexts import akka.grpc.scaladsl.SingleResponseRequestBuilder import akka.grpc.{ GrpcClientSettings, GrpcResponseMetadata, GrpcServiceException, GrpcSingleResponse } import akka.stream.{ Graph, Materializer, SourceShape } @@ -17,9 +16,9 @@ import akka.stream.scaladsl.{ Keep, Sink, Source } import akka.util.ByteString import io.grpc._ -import scala.compat.java8.FutureConverters._ import scala.concurrent.duration.Duration import scala.concurrent.{ ExecutionContext, Future } +import scala.jdk.FutureConverters._ /** * INTERNAL API @@ -88,10 +87,10 @@ final class JavaUnaryRequestBuilder[I, O]( this(descriptor, channel, defaultOptions, settings, MetadataImpl.empty) override def invoke(request: I): CompletionStage[O] = - delegate.invoke(request).toJava + delegate.invoke(request).asJava override def invokeWithMetadata(request: I): CompletionStage[GrpcSingleResponse[O]] = - delegate.invokeWithMetadata(request).toJava + delegate.invokeWithMetadata(request).asJava override def withHeaders(headers: MetadataImpl): JavaUnaryRequestBuilder[I, O] = new JavaUnaryRequestBuilder[I, O](descriptor, channel, defaultOptions, settings, headers) @@ -141,7 +140,7 @@ final class ScalaClientStreamingRequestBuilder[I, O]( NettyClientUtils.callOptionsWithDeadline(defaultOptions, settings) override def invoke(request: Source[I, NotUsed]): Future[O] = - invokeWithMetadata(request).map(_.value)(ExecutionContexts.parasitic).recoverWith(RequestBuilderImpl.richError) + invokeWithMetadata(request).map(_.value)(ExecutionContext.parasitic).recoverWith(RequestBuilderImpl.richError) override def invokeWithMetadata(source: Source[I, NotUsed]): Future[GrpcSingleResponse[O]] = { // a bit much overhead here because we are using the flow to represent a single response @@ -166,7 +165,7 @@ final class ScalaClientStreamingRequestBuilder[I, O]( def trailers = metadata.trailers def getTrailers() = metadata.getTrailers() } - }(ExecutionContexts.parasitic) + }(ExecutionContext.parasitic) .recoverWith(RequestBuilderImpl.richError) } @@ -217,10 +216,10 @@ final class JavaClientStreamingRequestBuilder[I, O]( new ScalaClientStreamingRequestBuilder[I, O](descriptor, channel, defaultOptions, settings, headers) override def invoke(request: JavaSource[I, NotUsed]): CompletionStage[O] = - delegate.invoke(request.asScala).toJava + delegate.invoke(request.asScala).asJava override def invokeWithMetadata(request: JavaSource[I, NotUsed]): CompletionStage[GrpcSingleResponse[O]] = - delegate.invokeWithMetadata(request.asScala).toJava + delegate.invokeWithMetadata(request.asScala).asJava override def withHeaders(headers: MetadataImpl): JavaClientStreamingRequestBuilder[I, O] = new JavaClientStreamingRequestBuilder[I, O](descriptor, channel, defaultOptions, settings, headers) @@ -328,7 +327,7 @@ final class JavaServerStreamingRequestBuilder[I, O]( delegate.invoke(request).asJava override def invokeWithMetadata(source: I): JavaSource[O, CompletionStage[GrpcResponseMetadata]] = - delegate.invokeWithMetadata(source).mapMaterializedValue(_.toJava).asJava + delegate.invokeWithMetadata(source).mapMaterializedValue(_.asJava).asJava override def withHeaders(headers: MetadataImpl): JavaServerStreamingRequestBuilder[I, O] = new JavaServerStreamingRequestBuilder[I, O](descriptor, channel, defaultOptions, settings, headers) @@ -438,7 +437,7 @@ final class JavaBidirectionalStreamingRequestBuilder[I, O]( override def invokeWithMetadata( source: JavaSource[I, NotUsed]): JavaSource[O, CompletionStage[GrpcResponseMetadata]] = - delegate.invokeWithMetadata(source.asScala).mapMaterializedValue(_.toJava).asJava + delegate.invokeWithMetadata(source.asScala).mapMaterializedValue(_.asJava).asJava override def withHeaders(headers: MetadataImpl): JavaBidirectionalStreamingRequestBuilder[I, O] = new JavaBidirectionalStreamingRequestBuilder[I, O](descriptor, channel, defaultOptions, settings, headers) diff --git a/runtime/src/main/scala/akka/grpc/internal/ServerReflectionImpl.scala b/runtime/src/main/scala/akka/grpc/internal/ServerReflectionImpl.scala index 98c04bc7d..9f445d8b3 100644 --- a/runtime/src/main/scala/akka/grpc/internal/ServerReflectionImpl.scala +++ b/runtime/src/main/scala/akka/grpc/internal/ServerReflectionImpl.scala @@ -13,7 +13,7 @@ import com.google.protobuf.ByteString import java.util.concurrent.ConcurrentHashMap import scala.collection.concurrent -import collection.JavaConverters._ +import scala.jdk.CollectionConverters._ /** * INTERNAL API @@ -105,7 +105,7 @@ final class ServerReflectionImpl private (fileDescriptors: Map[String, FileDescr */ @InternalApi object ServerReflectionImpl { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ def apply(fileDescriptors: Seq[FileDescriptor], services: List[String]): ServerReflectionImpl = { val fileDescriptorsWithDeps = (ReflectionProto.javaDescriptor +: fileDescriptors).toSet.flatMap(flattenDependencies) diff --git a/runtime/src/main/scala/akka/grpc/internal/SingleParameterSink.scala b/runtime/src/main/scala/akka/grpc/internal/SingleParameterSink.scala index 4fc442dbf..8e67e18bf 100644 --- a/runtime/src/main/scala/akka/grpc/internal/SingleParameterSink.scala +++ b/runtime/src/main/scala/akka/grpc/internal/SingleParameterSink.scala @@ -67,7 +67,7 @@ object SingleParameterSink { Sink.fromGraph(new SingleParameterStage[T]).withAttributes(Attributes.name("singleParameterSink")) def create[T](): javadsl.Sink[T, CompletionStage[T]] = { - import scala.compat.java8.FutureConverters._ - new javadsl.Sink(SingleParameterSink().mapMaterializedValue(_.toJava)) + import scala.jdk.FutureConverters._ + new javadsl.Sink(SingleParameterSink().mapMaterializedValue(_.asJava)) } } diff --git a/runtime/src/main/scala/akka/grpc/internal/UnaryCallAdapter.scala b/runtime/src/main/scala/akka/grpc/internal/UnaryCallAdapter.scala index 99970c8b4..53b7a8b4e 100644 --- a/runtime/src/main/scala/akka/grpc/internal/UnaryCallAdapter.scala +++ b/runtime/src/main/scala/akka/grpc/internal/UnaryCallAdapter.scala @@ -7,13 +7,13 @@ package akka.grpc.internal import java.util.concurrent.CompletionStage import akka.annotation.InternalApi -import akka.dispatch.ExecutionContexts import akka.grpc.GrpcSingleResponse import akka.util.OptionVal import io.grpc._ -import scala.compat.java8.FutureConverters._ +import scala.concurrent.ExecutionContext import scala.concurrent.{ Future, Promise } +import scala.jdk.FutureConverters._ /** * gRPC Netty based client listener transforming callbacks into a future response @@ -41,7 +41,7 @@ private[akka] final class UnaryCallAdapter[Res] extends ClientCall.Listener[Res] } def future: Future[Res] = responsePromise.future - def cs: CompletionStage[Res] = future.toJava + def cs: CompletionStage[Res] = future.asJava } /** @@ -80,9 +80,9 @@ private[akka] final class UnaryCallWithMetadataAdapter[Res] extends ClientCall.L override def getHeaders() = jMetadata private lazy val sTrailer = - trailerPromise.future.map(MetadataImpl.scalaMetadataFromGoogleGrpcMetadata)(ExecutionContexts.parasitic) + trailerPromise.future.map(MetadataImpl.scalaMetadataFromGoogleGrpcMetadata)(ExecutionContext.parasitic) private lazy val jTrailer = - trailerPromise.future.map(MetadataImpl.javaMetadataFromGoogleGrpcMetadata)(ExecutionContexts.parasitic).toJava + trailerPromise.future.map(MetadataImpl.javaMetadataFromGoogleGrpcMetadata)(ExecutionContext.parasitic).asJava def trailers = sTrailer def getTrailers() = jTrailer @@ -105,5 +105,5 @@ private[akka] final class UnaryCallWithMetadataAdapter[Res] extends ClientCall.L } def future: Future[GrpcSingleResponse[Res]] = responsePromise.future - def cs: CompletionStage[GrpcSingleResponse[Res]] = future.toJava + def cs: CompletionStage[GrpcSingleResponse[Res]] = future.asJava } diff --git a/runtime/src/main/scala/akka/grpc/javadsl/MetadataBuilder.scala b/runtime/src/main/scala/akka/grpc/javadsl/MetadataBuilder.scala index 057653429..600ce254f 100644 --- a/runtime/src/main/scala/akka/grpc/javadsl/MetadataBuilder.scala +++ b/runtime/src/main/scala/akka/grpc/javadsl/MetadataBuilder.scala @@ -7,7 +7,7 @@ package akka.grpc.javadsl import java.lang.{ Iterable => jIterable } import akka.annotation.ApiMayChange -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import akka.http.javadsl.model.{ HttpHeader, HttpMessage } import akka.http.scaladsl.model.{ HttpHeader => sHttpHeader, HttpMessage => sHttpMessage } import akka.http.scaladsl.model.headers.RawHeader diff --git a/runtime/src/main/scala/akka/grpc/javadsl/ServerReflection.scala b/runtime/src/main/scala/akka/grpc/javadsl/ServerReflection.scala index ff8bef3fd..8e5ff6bfa 100644 --- a/runtime/src/main/scala/akka/grpc/javadsl/ServerReflection.scala +++ b/runtime/src/main/scala/akka/grpc/javadsl/ServerReflection.scala @@ -21,15 +21,15 @@ object ServerReflection { def create( objects: Collection[ServiceDescription], sys: ClassicActorSystemProvider): akka.japi.function.Function[HttpRequest, CompletionStage[HttpResponse]] = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ val delegate = ServerReflectionHandler.apply( ServerReflectionImpl(objects.asScala.map(_.descriptor).toSeq, objects.asScala.map(_.name).toList))(sys) - import scala.compat.java8.FutureConverters._ + import scala.jdk.FutureConverters._ implicit val ec = sys.classicSystem.dispatcher request => delegate .apply(request.asInstanceOf[akka.http.scaladsl.model.HttpRequest]) .map(_.asInstanceOf[HttpResponse]) - .toJava + .asJava } } diff --git a/runtime/src/main/scala/akka/grpc/javadsl/WebHandler.scala b/runtime/src/main/scala/akka/grpc/javadsl/WebHandler.scala index 515be48c3..3e74cc78f 100644 --- a/runtime/src/main/scala/akka/grpc/javadsl/WebHandler.scala +++ b/runtime/src/main/scala/akka/grpc/javadsl/WebHandler.scala @@ -46,12 +46,12 @@ object WebHandler { // Adapt Marshaller.futureMarshaller(fromResponse) to javadsl private implicit val csResponseMarshaller: ToResponseMarshaller[CompletionStage[HttpResponse]] = { - import scala.compat.java8.FutureConverters._ + import scala.jdk.FutureConverters._ // HACK: Only known way to lift this to the scaladsl.model types required for MarshallingDirectives.handleWith Marshaller.asScalaToResponseMarshaller( Marshaller .fromScala(sMarshaller.futureMarshaller(sMarshaller.opaque(ConstantFun.scalaIdentityFunction[HttpResponse]))) - .compose[CompletionStage[HttpResponse]](_.toScala)) + .compose[CompletionStage[HttpResponse]](_.asScala)) } /** @@ -67,7 +67,7 @@ object WebHandler { as: ClassicActorSystemProvider, mat: Materializer, corsSettings: CorsSettings): JFunction[HttpRequest, CompletionStage[HttpResponse]] = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ val servicesHandler = concatOrNotFound(handlers.asScala.toList: _*) val servicesRoute = RouteAdapter(MarshallingDirectives.handleWith(servicesHandler.apply(_))) diff --git a/runtime/src/main/scala/akka/grpc/scaladsl/headers/headers.scala b/runtime/src/main/scala/akka/grpc/scaladsl/headers/headers.scala index 8e552a024..066a66ac9 100644 --- a/runtime/src/main/scala/akka/grpc/scaladsl/headers/headers.scala +++ b/runtime/src/main/scala/akka/grpc/scaladsl/headers/headers.scala @@ -35,7 +35,7 @@ object `Message-Accept-Encoding` extends ModeledCustomHeaderCompanion[`Message-A /** Java API */ def findIn(headers: java.lang.Iterable[jm.HttpHeader]): Array[String] = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ findIn(headers.asScala) } } @@ -60,7 +60,7 @@ object `Message-Encoding` extends ModeledCustomHeaderCompanion[`Message-Encoding /** Java API */ def findIn(headers: java.lang.Iterable[jm.HttpHeader]): Option[String] = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ findIn(headers.asScala) } } diff --git a/runtime/src/test/scala/akka/grpc/internal/AkkaDiscoveryNameResolverProviderSpec.scala b/runtime/src/test/scala/akka/grpc/internal/AkkaDiscoveryNameResolverProviderSpec.scala index c78a2afa9..5637dd2dc 100644 --- a/runtime/src/test/scala/akka/grpc/internal/AkkaDiscoveryNameResolverProviderSpec.scala +++ b/runtime/src/test/scala/akka/grpc/internal/AkkaDiscoveryNameResolverProviderSpec.scala @@ -62,7 +62,7 @@ class AkkaDiscoveryNameResolverProviderSpec val addressGroupsPromise = Promise[List[EquivalentAddressGroup]]() val listener = new Listener() { override def onAddresses(addresses: JList[EquivalentAddressGroup], attributes: Attributes): Unit = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ addressGroupsPromise.success(addresses.asScala.toList) } override def onError(error: io.grpc.Status): Unit = ??? diff --git a/runtime/src/test/scala/akka/grpc/internal/AkkaDiscoveryNameResolverSpec.scala b/runtime/src/test/scala/akka/grpc/internal/AkkaDiscoveryNameResolverSpec.scala index 34ad1008b..8e3bf8281 100644 --- a/runtime/src/test/scala/akka/grpc/internal/AkkaDiscoveryNameResolverSpec.scala +++ b/runtime/src/test/scala/akka/grpc/internal/AkkaDiscoveryNameResolverSpec.scala @@ -14,7 +14,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.time.{ Millis, Seconds, Span } import org.scalatest.wordspec.AnyWordSpecLike -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters._ import scala.concurrent.ExecutionContext class AkkaDiscoveryNameResolverSpec diff --git a/runtime/src/test/scala/akka/grpc/internal/NameResolverListenerProbe.scala b/runtime/src/test/scala/akka/grpc/internal/NameResolverListenerProbe.scala index 2e4a0a69d..26b030eeb 100644 --- a/runtime/src/test/scala/akka/grpc/internal/NameResolverListenerProbe.scala +++ b/runtime/src/test/scala/akka/grpc/internal/NameResolverListenerProbe.scala @@ -15,7 +15,7 @@ class NameResolverListenerProbe extends NameResolver.Listener { private val promise = Promise[Seq[EquivalentAddressGroup]]() override def onAddresses(servers: util.List[EquivalentAddressGroup], attributes: Attributes): Unit = { - import scala.collection.JavaConverters._ + import scala.jdk.CollectionConverters._ promise.trySuccess(servers.asScala.toSeq) } diff --git a/samples/akka-grpc-quickstart-java/build.gradle b/samples/akka-grpc-quickstart-java/build.gradle index 106a185c3..7cdb203b6 100644 --- a/samples/akka-grpc-quickstart-java/build.gradle +++ b/samples/akka-grpc-quickstart-java/build.gradle @@ -21,15 +21,15 @@ repositories { dependencies { implementation 'org.scala-lang:scala-library:2.13.13' - implementation 'com.typesafe.akka:akka-actor-typed_2.13:2.9.3' - implementation 'com.typesafe.akka:akka-discovery_2.13:2.9.3' - implementation 'com.typesafe.akka:akka-stream_2.13:2.9.3' - implementation 'com.typesafe.akka:akka-pki_2.13:2.9.3' + implementation 'com.typesafe.akka:akka-actor-typed_2.13:2.10.0-M1' + implementation 'com.typesafe.akka:akka-discovery_2.13:2.10.0-M1' + implementation 'com.typesafe.akka:akka-stream_2.13:2.10.0-M1' + implementation 'com.typesafe.akka:akka-pki_2.13:2.10.0-M1' implementation 'ch.qos.logback:logback-classic:1.2.13' - testImplementation 'com.typesafe.akka:akka-actor-testkit-typed_2.13:2.9.3' - testImplementation 'com.typesafe.akka:akka-stream-testkit_2.13:2.9.3' + testImplementation 'com.typesafe.akka:akka-actor-testkit-typed_2.13:2.10.0-M1' + testImplementation 'com.typesafe.akka:akka-stream-testkit_2.13:2.10.0-M1' testImplementation 'junit:junit:4.13' } diff --git a/samples/akka-grpc-quickstart-java/build.sbt b/samples/akka-grpc-quickstart-java/build.sbt index 33c26b154..d2ed7af14 100644 --- a/samples/akka-grpc-quickstart-java/build.sbt +++ b/samples/akka-grpc-quickstart-java/build.sbt @@ -2,7 +2,7 @@ name := "akka-grpc-quickstart-java" version := "1.0" scalaVersion := "2.13.14" -val akkaVersion = "2.9.3" +val akkaVersion = "2.10.0-M1" lazy val akkaGrpcVersion = sys.props.getOrElse("akka-grpc.version", "2.4.3") enablePlugins(AkkaGrpcPlugin) diff --git a/samples/akka-grpc-quickstart-java/pom.xml b/samples/akka-grpc-quickstart-java/pom.xml index 5fa8459ca..cad88e2e3 100644 --- a/samples/akka-grpc-quickstart-java/pom.xml +++ b/samples/akka-grpc-quickstart-java/pom.xml @@ -11,7 +11,7 @@ 17 17 - 2.9.3 + 2.10.0-M1 2.4.3 2.13 UTF-8 diff --git a/samples/akka-grpc-quickstart-scala/build.gradle b/samples/akka-grpc-quickstart-scala/build.gradle index 45f9ba815..bb412451e 100644 --- a/samples/akka-grpc-quickstart-scala/build.gradle +++ b/samples/akka-grpc-quickstart-scala/build.gradle @@ -21,15 +21,15 @@ repositories { dependencies { implementation 'org.scala-lang:scala-library:2.13.13' - implementation 'com.typesafe.akka:akka-actor-typed_2.13:2.9.3' - implementation 'com.typesafe.akka:akka-discovery_2.13:2.9.3' - implementation 'com.typesafe.akka:akka-stream_2.13:2.9.3' - implementation 'com.typesafe.akka:akka-pki_2.13:2.9.3' + implementation 'com.typesafe.akka:akka-actor-typed_2.13:2.10.0-M1' + implementation 'com.typesafe.akka:akka-discovery_2.13:2.10.0-M1' + implementation 'com.typesafe.akka:akka-stream_2.13:2.10.0-M1' + implementation 'com.typesafe.akka:akka-pki_2.13:2.10.0-M1' implementation 'ch.qos.logback:logback-classic:1.2.13' - testImplementation 'com.typesafe.akka:akka-actor-testkit-typed_2.13:2.9.3' - testImplementation 'com.typesafe.akka:akka-stream-testkit_2.13:2.9.3' + testImplementation 'com.typesafe.akka:akka-actor-testkit-typed_2.13:2.10.0-M1' + testImplementation 'com.typesafe.akka:akka-stream-testkit_2.13:2.10.0-M1' testImplementation 'org.scalatest:scalatest_2.13:3.2.12' // optional in Scalatest testRuntimeOnly 'com.vladsch.flexmark:flexmark-all:0.62.2' diff --git a/samples/akka-grpc-quickstart-scala/build.sbt b/samples/akka-grpc-quickstart-scala/build.sbt index d97015d41..75291983a 100644 --- a/samples/akka-grpc-quickstart-scala/build.sbt +++ b/samples/akka-grpc-quickstart-scala/build.sbt @@ -3,7 +3,7 @@ name := "akka-grpc-quickstart-scala" version := "1.0" scalaVersion := "2.13.14" -val akkaVersion = "2.9.3" +val akkaVersion = "2.10.0-M1" lazy val akkaGrpcVersion = sys.props.getOrElse("akka-grpc.version", "2.4.3") enablePlugins(AkkaGrpcPlugin) diff --git a/samples/akka-grpc-quickstart-scala/pom.xml b/samples/akka-grpc-quickstart-scala/pom.xml index 972d1dee8..f44436e34 100644 --- a/samples/akka-grpc-quickstart-scala/pom.xml +++ b/samples/akka-grpc-quickstart-scala/pom.xml @@ -11,7 +11,7 @@ 17 17 - 2.9.3 + 2.10.0-M1 2.4.3 2.13 UTF-8 diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/01-gen-basic-server/build.sbt b/sbt-plugin/src/sbt-test/gen-scala-server/01-gen-basic-server/build.sbt index dba98a669..ad13d1510 100644 --- a/sbt-plugin/src/sbt-test/gen-scala-server/01-gen-basic-server/build.sbt +++ b/sbt-plugin/src/sbt-test/gen-scala-server/01-gen-basic-server/build.sbt @@ -10,6 +10,7 @@ assembly / assemblyMergeStrategy := { // https://github.com/akka/akka/issues/29456 case PathList("google", "protobuf", _) => MergeStrategy.discard case PathList("google", "protobuf", _, _) => MergeStrategy.discard + case "META-INF/versions/9/module-info.class" => MergeStrategy.discard case x => val oldStrategy = (assemblyMergeStrategy in assembly).value oldStrategy(x) diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/01-gen-basic-server/project/build.properties b/sbt-plugin/src/sbt-test/gen-scala-server/01-gen-basic-server/project/build.properties new file mode 100644 index 000000000..e8a1e246e --- /dev/null +++ b/sbt-plugin/src/sbt-test/gen-scala-server/01-gen-basic-server/project/build.properties @@ -0,0 +1 @@ +sbt.version=1.9.7 diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/07-gen-basic-server-with-akka-27/build.sbt b/sbt-plugin/src/sbt-test/gen-scala-server/07-gen-basic-server-with-akka-27/build.sbt index 8893aba2e..6cfdc23d6 100644 --- a/sbt-plugin/src/sbt-test/gen-scala-server/07-gen-basic-server-with-akka-27/build.sbt +++ b/sbt-plugin/src/sbt-test/gen-scala-server/07-gen-basic-server-with-akka-27/build.sbt @@ -4,12 +4,13 @@ resolvers += "Akka library repository".at("https://repo.akka.io/maven") enablePlugins(AkkaGrpcPlugin) -dependencyOverrides += "com.typesafe.akka" %% "akka-stream" % "2.9.3" +dependencyOverrides += "com.typesafe.akka" %% "akka-stream" % "2.10.0-M1" assembly / assemblyMergeStrategy := { // https://github.com/akka/akka/issues/29456 case PathList("google", "protobuf", _) => MergeStrategy.discard case PathList("google", "protobuf", _, _) => MergeStrategy.discard + case "META-INF/versions/9/module-info.class" => MergeStrategy.discard case x => val oldStrategy = (assembly / assemblyMergeStrategy).value oldStrategy(x)