Skip to content

Commit

Permalink
Merge pull request #11122 from xuwei-k/JavaConverters
Browse files Browse the repository at this point in the history
use CollectionConverters instead of deprecated JavaConverters
  • Loading branch information
mergify[bot] committed Jan 24, 2022
2 parents fe48613 + 9a2b691 commit dfc0b2f
Show file tree
Hide file tree
Showing 67 changed files with 84 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ trait CaffeineCacheComponents {
*/
class CaffeineCacheModule
extends SimpleModule((environment, configuration) => {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

val defaultCacheName = configuration.underlying.getString("play.cache.defaultCache")
val bindCaches = configuration.underlying.getStringList("play.cache.bindCaches").asScala
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CaffeineCacheManager(private val config: Config, private val actorSystem:
}

def cacheNames: Set[String] = {
scala.collection.JavaConverters.asScalaSet(cacheMap.keySet()).toSet
scala.jdk.CollectionConverters.SetHasAsScala(cacheMap.keySet()).asScala.toSet
}

private[caffeine] def getCacheBuilder(cacheName: String): Caffeine[_, _] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class CaffeineCacheApiSpec extends PlaySpecification {
"play.cache.bindCaches" -> Seq("custom")
)
) {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val caffeineCacheManager: CaffeineCacheManager = app.injector.instanceOf[CaffeineCacheManager]
caffeineCacheManager.getCache("custom")
caffeineCacheManager.getCache("custom-two")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ trait EhCacheComponents {
*/
class EhCacheModule
extends SimpleModule((environment, configuration) => {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

val defaultCacheName = configuration.underlying.getString("play.cache.defaultCache")
val bindCaches = configuration.underlying.getStringList("play.cache.bindCaches").asScala
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ final case class GuiceApplicationBuilder(
* @return Returns true if one of the keys contains a deprecated value, otherwise false
*/
def shouldDisplayLoggerDeprecationMessage(appConfiguration: Configuration): Boolean = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.collection.mutable

val deprecatedValues = List("DEBUG", "WARN", "ERROR", "INFO", "TRACE", "OFF")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import play.api.Environment
import play.api.Mode
import play.api.PlayException

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.reflect.ClassTag

class GuiceLoadException(message: String) extends RuntimeException(message)
Expand Down Expand Up @@ -169,7 +169,7 @@ abstract class GuiceBuilder[Self] protected (
* Libraries like Guiceberry and Jukito that want to handle injector creation may find this helpful.
*/
def createModule(): GuiceModule = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val injectorModule = GuiceableModule.guice(
Seq(
bind[GuiceInjector].toSelf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import play.i18n.MessagesApi
import scala.concurrent.duration.Duration
import scala.concurrent.Await
import scala.concurrent.Future
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.util.control.NoStackTrace

class HttpErrorHandlerSpec extends Specification {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ trait HeadActionSpec
val getHeaders: HttpHeaders = responses(1).underlying[NettyResponse].getHeaders

// Exclude `Date` header because it can vary between requests
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val firstHeaders = headHeaders.remove(DATE)
val secondHeaders = getHeaders.remove(DATE)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import play.core.server._
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext.Implicits._
import scala.util.Random
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

class AkkaRequestTimeoutSpec extends PlaySpecification with AkkaHttpIntegrationSpecification {
"play.server.akka.requestTimeout configuration" should {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import play.core.server.ServerEndpoint
import play.it.test.EndpointIntegrationSpecification
import play.it.test.OkHttpEndpointSupport

import scala.collection.JavaConverters
import scala.jdk.CollectionConverters

class FlashCookieSpec
extends PlaySpecification
Expand Down Expand Up @@ -64,7 +64,7 @@ class FlashCookieSpec
def withAllCookieEndpoints[A: AsResult](block: CookieEndpoint => A): Fragment = {
appFactory.withAllOkHttpEndpoints { (okEndpoint: OkHttpEndpoint) =>
block(new CookieEndpoint {
import JavaConverters._
import CollectionConverters._
def call(path: String, cookies: List[okhttp3.Cookie]): (okhttp3.Response, List[okhttp3.Cookie]) = {
var responseCookies: List[okhttp3.Cookie] = null
val cookieJar = new CookieJar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GuiceJavaActionCompositionSpec extends JavaActionCompositionSpec {

class BuiltInComponentsJavaActionCompositionSpec extends JavaActionCompositionSpec {
def context(initialSettings: Map[String, AnyRef]): play.ApplicationLoader.Context = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
play.ApplicationLoader.create(play.Environment.simple(), initialSettings.asJava)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class GuiceJavaActionSpec extends JavaActionSpec {

class BuiltInComponentsJavaActionSpec extends JavaActionSpec {
def context(initialSettings: Map[String, AnyRef]): play.ApplicationLoader.Context = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
play.ApplicationLoader.create(play.Environment.simple(), initialSettings.asJava)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class JavaHttpErrorHandlingSpec
): ApplicationFactory = new ApplicationFactory {
override def create(): ScalaApplication = {
val components = new BuiltInComponentsFromContext(applicationContext) with RoutingDslComponents {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.compat.java8.OptionConverters

// Add the web command handler if it is available
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import play.mvc.Http
import play.mvc.Http.RequestBody
import play.mvc.Http.RequestImpl

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

class JavaRequestsSpec extends PlaySpecification with Mockito {
"JavaHelpers" should {
Expand All @@ -39,7 +39,7 @@ class JavaRequestsSpec extends PlaySpecification with Mockito {
}

"create a request with a helper that can do cookies" in {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

val cookie1 = Cookie("name1", "value1")
val requestHeader: RequestHeader = FakeRequest().withCookies(cookie1)
Expand All @@ -54,7 +54,7 @@ class JavaRequestsSpec extends PlaySpecification with Mockito {
}

"create a request with a helper that can do cookies" in {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

val cookie1 = Cookie("name1", "value1")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import play.mvc.Http.Flash
import play.mvc.Http.Session
import play.mvc._

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

class NettyJavaResultsHandlingSpec extends JavaResultsHandlingSpec with NettyIntegrationSpecification
class AkkaHttpJavaResultsHandlingSpec extends JavaResultsHandlingSpec with AkkaHttpIntegrationSpecification
Expand Down Expand Up @@ -499,7 +499,7 @@ trait JavaResultsHandlingSpec
.withCookies(new Http.Cookie("bar", "KitKat", 1000, "/", "example.com", false, true, null))
.withCookies(new Http.Cookie("bar", "Mars", 1000, "/", "example.com", false, true, null))

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val cookies = result.cookies().iterator().asScala.toList
val cookieValues = cookies.map(_.value)
cookieValues must not contain ("KitKat")
Expand Down Expand Up @@ -558,7 +558,7 @@ trait JavaResultsHandlingSpec

"chunk comet results from string" in makeRequest(new MockController {
def action(request: Http.Request) = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val dataSource = akka.stream.javadsl.Source.from(List("a", "b", "c").asJava)
val cometSource = dataSource.via(Comet.string("callback"))
Results.ok().chunked(cometSource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ trait SessionCookieSpec extends PlaySpecification with ServerIntegrationSpecific
Server.withApplicationFromContext() { context =>
new BuiltInComponentsFromContext(context) with NoHttpFiltersComponents {
import play.api.routing.sird.{ GET => SirdGet, _ }
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

override def configuration: Configuration =
Configuration(ConfigFactory.parseMap(additionalConfiguration.asJava)).withFallback(super.configuration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import play.api.test.Injecting
import play.api.test.PlaySpecification
import play.api.test.WithApplication

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.concurrent.Future

class FormBodyParserSpec extends PlaySpecification {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ object WebSocketClient {
val clientConnection =
Flow.fromSinkAndSource(Sink.fromSubscriber(subscriber), Source.fromPublisher(publisher))

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val responseHeaders = resp.headers().entries().asScala.toList.map(entry => (entry.getKey, entry.getValue))
onConnected(responseHeaders, webSocketProtocol(clientConnection))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ trait WebSocketSpec
import play.core.routing.HandlerInvokerFactory
import play.core.routing.HandlerInvokerFactory._

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

implicit def toHandler[J <: AnyRef](
javaHandler: => J
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import play.data.validation.Constraints.Required

import scala.annotation.meta.field
import scala.beans.BeanProperty
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

class JavaFormSpec extends PlaySpecification {
"A Java form" should {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import play.mvc.Http.RequestBody
import play.mvc.Result
import play.utils.UriEncoding

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.compat.java8.FutureConverters
import scala.concurrent.ExecutionContext
import scala.concurrent.Future
Expand Down
2 changes: 1 addition & 1 deletion core/play-java/src/test/scala/play/libs/XPathSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
package play.libs

import org.specs2.mutable.Specification
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

class XPathSpec extends Specification {
//XPathFactory.newInstance() used internally by XPath is not thread safe so forcing sequential execution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import akka.japi.function.{ Function => JFn }
import org.reactivestreams.Subscription

class AccumulatorSpec extends org.specs2.mutable.Specification {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

def withMaterializer[T](block: Materializer => T): T = {
val system = ActorSystem("test")
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/Configuration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import com.typesafe.config._
import play.twirl.api.utils.StringEscapeUtils
import play.utils.PlayIO

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.concurrent.duration.Duration
import scala.concurrent.duration.FiniteDuration
import scala.util.control.NonFatal
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/Logger.scala
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import org.slf4j.Marker

import scala.collection.mutable
import scala.language.implicitConversions
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* Typical logger interface.
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/LoggerConfigurator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ object LoggerConfigurator {
config: Configuration,
optionalProperties: Map[String, String]
): Map[String, String] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
val mutableMap = new scala.collection.mutable.HashMap[String, String]()
mutableMap.put("application.home", env.rootPath.getAbsolutePath)

Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/http/HttpFilters.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import play.api.Logger
import play.api.mvc.EssentialFilter
import play.utils.Reflect

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* Provides filters to the [[play.api.http.HttpRequestHandler]].
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/i18n/Langs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import play.api.Logger

import scala.util.Try
import scala.util.control.NonFatal
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

/**
* A Lang supported by the application.
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/i18n/Messages.scala
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ class DefaultMessagesApiProvider @Inject() (
}

protected def loadMessages(file: String): Map[String, String] = {
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

environment.classLoader
.getResources(joinPaths(messagesPrefix, file))
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/mvc/Binders.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import java.util.OptionalLong
import java.util.UUID
import scala.annotation._

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.compat.java8.OptionConverters._

import reflect.ClassTag
Expand Down
6 changes: 3 additions & 3 deletions core/play/src/main/scala/play/api/mvc/Cookie.scala
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ trait CookieHeaderEncoding {
val SetCookieHeaderSeparator = ";;"
val SetCookieHeaderSeparatorRegex = SetCookieHeaderSeparator.r

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

// We use netty here but just as an API to handle cookies encoding

Expand Down Expand Up @@ -648,7 +648,7 @@ trait JWTCookieDataCodec extends CookieDataCodec {
override def decode(encodedString: String): Map[String, String] = {
import io.jsonwebtoken._

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

try {
// Get all the claims
Expand Down Expand Up @@ -722,7 +722,7 @@ object JWTCookieDataCodec {
clock: java.time.Clock
) {
import io.jsonwebtoken._
import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

private val jwtClock = new Clock {
override def now(): Date = java.util.Date.from(clock.instant())
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/mvc/Headers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import java.util.Locale
import play.api.http.HeaderNames
import play.core.utils.CaseInsensitiveOrdered

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._

import scala.collection.immutable.TreeMap
import scala.collection.immutable.TreeSet
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/mvc/Results.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import play.api.libs.typedmap.TypedMap
import play.core.utils.CaseInsensitiveOrdered
import play.core.utils.HttpHeaderParameterEncoding

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.collection.immutable.TreeMap
import scala.concurrent.ExecutionContext

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import java.util.Optional

import play.twirl.api.Html

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.compat.java8.OptionConverters._

/** Defines a magic helper for Play templates. */
Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/core/j/JavaAction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import play.libs.AnnotationUtils
import play.mvc.Http.{ Request => JRequest }
import play.mvc.Http.{ RequestImpl => JRequestImpl }

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.concurrent.ExecutionContext
import scala.concurrent.Future

Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/core/j/JavaHelpers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import play.mvc.Http.{ RequestHeader => JRequestHeader }
import play.mvc.Http.{ RequestImpl => JRequestImpl }
import play.mvc.Http

import scala.collection.JavaConverters._
import scala.jdk.CollectionConverters._
import scala.compat.java8.OptionConverters

/**
Expand Down

0 comments on commit dfc0b2f

Please sign in to comment.