Skip to content

Commit 86d81cf

Browse files
authored
use Scala converters in more places (#774)
* add more use of scala conversions * Update JavaMapping.scala * Update FormFieldDirectives.scala
1 parent 9bbea64 commit 86d81cf

File tree

11 files changed

+20
-21
lines changed

11 files changed

+20
-21
lines changed

http-core/src/main/scala/org/apache/pekko/http/impl/model/JavaUri.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ private[http] case class JavaUri(uri: sm.Uri) extends jm.Uri {
5252
case Segment(head, tail) => head :: gatherSegments(tail)
5353
case Slash(tail) => gatherSegments(tail)
5454
}
55-
import collection.JavaConverters._
55+
import scala.jdk.CollectionConverters._
5656
gatherSegments(uri.path).asJava
5757
}
5858

http-core/src/main/scala/org/apache/pekko/http/impl/model/UriJavaAccessor.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private[http] abstract class UriJavaAccessor
3030
*/
3131
@InternalApi
3232
private[http] object UriJavaAccessor {
33-
import collection.JavaConverters._
33+
import scala.jdk.CollectionConverters._
3434

3535
def hostApply(string: String): Host = Uri.Host(string)
3636
def hostApply(string: String, mode: Uri.ParsingMode): Host = Uri.Host(string, mode = mode)

http-core/src/main/scala/org/apache/pekko/http/impl/util/JavaMapping.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ import org.apache.pekko
2222
import pekko.japi.Pair
2323
import pekko.stream.{ javadsl, scaladsl, FlowShape, Graph }
2424

25-
import scala.collection.immutable
26-
import scala.reflect.ClassTag
2725
import pekko.NotUsed
2826
import pekko.annotation.InternalApi
2927
import pekko.http.impl.model.{ JavaQuery, JavaUri }
@@ -37,9 +35,11 @@ import pekko.http.javadsl.{
3735
import pekko.http.{ javadsl => jdsl, scaladsl => sdsl }
3836
import pekko.http.scaladsl.{ model => sm }
3937
import pekko.util.FutureConverters._
40-
import pekko.util.OptionConverters._
4138

39+
import scala.collection.immutable
4240
import scala.concurrent.{ ExecutionContext, Future }
41+
import scala.jdk.OptionConverters._
42+
import scala.reflect.ClassTag
4343
import scala.util.Try
4444

4545
/** INTERNAL API */
@@ -122,15 +122,15 @@ private[http] object JavaMapping {
122122
implicit def iterableMapping[_J, _S](
123123
implicit mapping: JavaMapping[_J, _S]): JavaMapping[jl.Iterable[_J], immutable.Seq[_S]] =
124124
new JavaMapping[jl.Iterable[_J], immutable.Seq[_S]] {
125-
import collection.JavaConverters._
125+
import scala.jdk.CollectionConverters._
126126

127127
def toJava(scalaObject: immutable.Seq[_S]): jl.Iterable[_J] = scalaObject.map(mapping.toJava).asJavaCollection
128128
def toScala(javaObject: jl.Iterable[_J]): immutable.Seq[_S] =
129-
Implicits.convertSeqToScala(iterableAsScalaIterableConverter(javaObject).asScala.toSeq)
129+
Implicits.convertSeqToScala(javaObject.asScala.toSeq)
130130
}
131131
implicit def map[K, V]: JavaMapping[ju.Map[K, V], immutable.Map[K, V]] =
132132
new JavaMapping[ju.Map[K, V], immutable.Map[K, V]] {
133-
import scala.collection.JavaConverters._
133+
import scala.jdk.CollectionConverters._
134134
def toScala(javaObject: ju.Map[K, V]): immutable.Map[K, V] = javaObject.asScala.toMap
135135
def toJava(scalaObject: immutable.Map[K, V]): ju.Map[K, V] = scalaObject.asJava
136136
}

http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/Http2ServerSettings.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ import java.time.Duration
1818
import org.apache.pekko
1919
import pekko.annotation.DoNotInherit
2020
import pekko.http.scaladsl
21-
import pekko.util.ccompat.JavaConverters._
2221
import com.typesafe.config.Config
22+
2323
import scala.concurrent.duration._
24+
import scala.jdk.CollectionConverters._
2425

2526
@DoNotInherit
2627
trait Http2ServerSettings {

http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpCharset.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ final case class HttpCharset private[http] (override val value: String)(val alia
8989

9090
/** Java API */
9191
def getAliases: JIterable[String] = {
92-
import collection.JavaConverters._
92+
import scala.jdk.CollectionConverters._
9393
aliases.asJava
9494
}
9595
}

http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ sealed trait HttpMessage extends jm.HttpMessage {
210210

211211
def transformEntityDataBytes[M](transformer: Graph[FlowShape[ByteString, ByteString], M]): Self
212212

213-
import collection.JavaConverters._
213+
import scala.jdk.CollectionConverters._
214214

215215
/** Java API */
216216
def getHeaders: JIterable[jm.HttpHeader] = (headers: immutable.Seq[jm.HttpHeader]).asJava

http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/MediaRange.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ sealed abstract class MediaRange extends jm.MediaRange with Renderable with With
4747

4848
/** Java API */
4949
def getParams: util.Map[String, String] = {
50-
import collection.JavaConverters._
50+
import scala.jdk.CollectionConverters._
5151
params.asJava
5252
}
5353

http-core/src/main/scala/org/apache/pekko/http/scaladsl/settings/Http2ServerSettings.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ import pekko.annotation.DoNotInherit
1919
import pekko.annotation.InternalApi
2020
import pekko.http.impl.util._
2121
import pekko.http.javadsl
22-
import pekko.util.ccompat.JavaConverters._
2322
import com.typesafe.config.Config
2423

2524
import scala.concurrent.duration.Duration
2625
import scala.concurrent.duration.FiniteDuration
26+
import scala.jdk.CollectionConverters._
2727

2828
/**
2929
* INTERNAL API

http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/FormFieldDirectives.scala

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ import java.util.function.{ Function => JFunction }
2020

2121
import org.apache.pekko
2222
import pekko.http.javadsl.unmarshalling.Unmarshaller
23-
24-
import scala.collection.JavaConverters._
25-
import pekko.http.impl.util.JavaMapping.Implicits._
26-
2723
import pekko.http.javadsl.server.Route
28-
2924
import pekko.http.scaladsl.server.{ Directives => D }
3025
import pekko.http.scaladsl.server.directives.ParameterDirectives._
31-
import pekko.util.OptionConverters._
26+
27+
import scala.jdk.CollectionConverters._
28+
import pekko.http.impl.util.JavaMapping.Implicits._
29+
import scala.jdk.OptionConverters._
3230

3331
abstract class FormFieldDirectives extends FileUploadDirectives {
3432

http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/HeaderDirectives.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import pekko.http.javadsl.model.HttpHeader
2525
import pekko.http.javadsl.server.Route
2626
import pekko.http.scaladsl.model.headers.{ ModeledCustomHeader, ModeledCustomHeaderCompanion }
2727
import pekko.http.scaladsl.server.directives.{ HeaderDirectives => D, HeaderMagnet }
28-
import pekko.util.OptionConverters._
2928

29+
import scala.jdk.OptionConverters._
3030
import scala.reflect.ClassTag
3131
import scala.util.{ Failure, Success }
3232

0 commit comments

Comments
 (0)