Skip to content

Commit

Permalink
use Pekko JavaConverter
Browse files Browse the repository at this point in the history
Update VersionSyncCheckPlugin.scala

revert

Update JavaCodeGenerator.scala

revert

more changes

Update ServerReflectionImpl.scala

revert more
  • Loading branch information
pjfanning committed Nov 3, 2024
1 parent 077b7d4 commit 71ea016
Show file tree
Hide file tree
Showing 16 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

package org.apache.pekko.grpc.gen.scaladsl

import scala.collection.immutable
import scala.collection.JavaConverters._
import scala.collection.immutable
import com.google.protobuf.Descriptors._
import protocgen.CodeGenRequest
import scalapb.compiler.{ DescriptorImplicits, GeneratorParams }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import org.apache.pekko.NotUsed;
import org.apache.pekko.grpc.GrpcServiceException;
import org.apache.pekko.stream.javadsl.Source;
import scala.collection.JavaConverters;
import org.apache.pekko.util.ccompat.JavaConverters;

public class RichErrorNativeImpl implements GreeterService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ abstract class AbstractGenerateMojo @Inject() (buildContext: BuildContext) exten
@BeanProperty
var generatePlayServer: Boolean = _

import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._
@BeanProperty
var generatorSettings: java.util.Map[String, String] = _

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ProtocSpec extends AnyWordSpec with Matchers {
}
}

import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._

"Parsing generator settings" should {
"filter out the false values" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import javax.net.ssl.{ TrustManager, TrustManagerFactory }
object SSLContextUtils {
def trustManagerFromStream(certStream: InputStream): TrustManager = {
try {
import scala.collection.JavaConverters._
import org.apache.pekko.util.ccompat.JavaConverters._
val cf = CertificateFactory.getInstance("X.509")
val bis = new BufferedInputStream(certStream)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ object Codecs {
case sReq: sm.HttpMessage =>
sReq.headers
case _ =>
import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._
request.getHeaders.asScala
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ package org.apache.pekko.grpc.internal

import java.util.{ List => jList, Locale, Map => jMap, Optional }

import scala.collection.JavaConverters._
import scala.collection.immutable
import org.apache.pekko
import pekko.annotation.InternalApi
import pekko.http.scaladsl.model.HttpHeader
import pekko.japi.Pair
import pekko.util.ByteString
import pekko.util.ccompat.JavaConverters._
import pekko.grpc.scaladsl.{ BytesEntry, Metadata, MetadataEntry, StringEntry }
import pekko.grpc.javadsl
import pekko.util.OptionConverters._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class PekkoDiscoveryNameResolver(

@throws[UnknownHostException]
private def addresses(addresses: Seq[ResolvedTarget]) = {
import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._
addresses
.map(target => {
val port = target.port.getOrElse(defaultPort)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import org.apache.pekko
import pekko.NotUsed
import pekko.annotation.InternalApi
import pekko.stream.scaladsl._
import pekko.util.ccompat.JavaConverters._
import _root_.grpc.reflection.v1alpha.reflection._
import com.google.protobuf.ByteString

import java.util.concurrent.ConcurrentHashMap
import scala.collection.concurrent
import collection.JavaConverters._

/**
* INTERNAL API
Expand Down Expand Up @@ -77,7 +77,7 @@ final class ServerReflectionImpl private (fileDescriptors: Map[String, FileDescr
*/
@InternalApi
object ServerReflectionImpl {
import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._

def apply(fileDescriptors: Seq[FileDescriptor], services: List[String]): ServerReflectionImpl = {
val fileDescriptorsWithDeps = (ReflectionProto.javaDescriptor +: fileDescriptors).toSet.flatMap(flattenDependencies)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import java.lang.{ Iterable => jIterable }
import org.apache.pekko
import pekko.annotation.ApiMayChange

import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._
import pekko.http.javadsl.model.HttpHeader
import pekko.http.scaladsl.model.{ HttpHeader => sHttpHeader }
import pekko.http.scaladsl.model.headers.RawHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ object ServerReflection {
def create(
objects: Collection[ServiceDescription],
sys: ClassicActorSystemProvider): pekko.japi.function.Function[HttpRequest, CompletionStage[HttpResponse]] = {
import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._
val delegate = ServerReflectionHandler.apply(
ServerReflectionImpl(objects.asScala.map(_.descriptor).toSeq, objects.asScala.map(_.name).toList))(sys)
import pekko.util.FutureConverters._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ object WebHandler {
as: ClassicActorSystemProvider,
mat: Materializer,
corsSettings: CorsSettings): JFunction[HttpRequest, CompletionStage[HttpResponse]] = {
import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._

val servicesHandler = concatOrNotFound(handlers.asScala.toList: _*)
val servicesRoute = RouteAdapter(MarshallingDirectives.handleWith(servicesHandler.apply(_)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,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 pekko.util.ccompat.JavaConverters._
findIn(headers.asScala)
}
}
Expand All @@ -70,7 +70,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 pekko.util.ccompat.JavaConverters._
findIn(headers.asScala)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,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 pekko.util.ccompat.JavaConverters._
promise.trySuccess(servers.asScala.toSeq)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PekkoDiscoveryNameResolverProviderSpec
val addressGroupsPromise = Promise[List[EquivalentAddressGroup]]()
val listener = new Listener() {
override def onAddresses(addresses: JList[EquivalentAddressGroup], attributes: Attributes): Unit = {
import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._
addressGroupsPromise.success(addresses.asScala.toList)
}
override def onError(error: io.grpc.Status): Unit = ???
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.scalatest.matchers.should.Matchers
import org.scalatest.time.{ Millis, Seconds, Span }
import org.scalatest.wordspec.AnyWordSpecLike

import scala.collection.JavaConverters._
import pekko.util.ccompat.JavaConverters._
import scala.concurrent.ExecutionContext

class PekkoDiscoveryNameResolverSpec
Expand Down

0 comments on commit 71ea016

Please sign in to comment.