Skip to content

Commit

Permalink
Merge pull request #11135 from xuwei-k/ArraySeq-unsafeWrapArray
Browse files Browse the repository at this point in the history
fix Seq implicit conversions warnings
  • Loading branch information
mergify[bot] committed Jan 31, 2022
2 parents c77b88e + 5541d1d commit 6c6480c
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 12 deletions.
4 changes: 2 additions & 2 deletions core/play/src/main/scala/play/api/http/AcceptEncoding.scala
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,9 @@ object AcceptEncoding {
private val logger = Logger(this.getClass())

val separatorChars = "()<>@,;:\\\"/[]?={} \t"
val separatorBitSet = BitSet(separatorChars.toCharArray.map(_.toInt): _*)
val separatorBitSet = separatorChars.toCharArray.map(_.toInt).to(BitSet)
val qChars = "Qq"
val qBitSet = BitSet(qChars.toCharArray.map(_.toInt): _*)
val qBitSet = qChars.toCharArray.map(_.toInt).to(BitSet)

type Elem = Char

Expand Down
2 changes: 1 addition & 1 deletion core/play/src/main/scala/play/api/http/MediaRange.scala
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ object MediaRange {
private val logger = Logger(this.getClass())

val separatorChars = "()<>@,;:\\\"/[]?={} \t"
val separatorBitSet = BitSet(separatorChars.toCharArray.map(_.toInt): _*)
val separatorBitSet = separatorChars.toCharArray.map(_.toInt).to(BitSet)

type Elem = Char

Expand Down
3 changes: 2 additions & 1 deletion core/play/src/main/scala/play/core/j/JavaAction.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import play.mvc.Http.{ Request => JRequest }
import play.mvc.Http.{ RequestImpl => JRequestImpl }

import scala.jdk.CollectionConverters._
import scala.collection.immutable.ArraySeq
import scala.concurrent.ExecutionContext
import scala.concurrent.Future

Expand Down Expand Up @@ -59,7 +60,7 @@ class JavaActionAnnotations(
.flatten

val actionMixins: Seq[(Annotation, Class[_ <: JAction[_]], AnnotatedElement)] = {
val methodAnnotations = method.getDeclaredAnnotations.map((_, method))
val methodAnnotations = ArraySeq.unsafeWrapArray(method.getDeclaredAnnotations.map((_, method)))
val allDeclaredAnnotations: Seq[(java.lang.annotation.Annotation, AnnotatedElement)] =
if (config.controllerAnnotationsFirst) {
controllerAnnotations ++ methodAnnotations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package play.core.parsers

import java.net.URLDecoder
import scala.collection.immutable.ArraySeq

/** An object for parsing application/x-www-form-urlencoded data */
object FormUrlEncodedParser {
Expand Down Expand Up @@ -78,12 +79,12 @@ object FormUrlEncodedParser {
if (split.length == 1 && split(0).isEmpty) {
Seq.empty
} else {
split.map { param =>
ArraySeq.unsafeWrapArray(split.map { param =>
val parts = param.split("=", -1)
val key = URLDecoder.decode(parts(0), encoding)
val value = URLDecoder.decode(parts.lift(1).getOrElse(""), encoding)
key -> value
}
})
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import play.api.Logger
import play.api.Mode
import play.core.DefaultWebCommands
import play.utils.PlayIO
import scala.collection.immutable.ArraySeq

/**
* An SQL evolution - database changes associated with a software version.
Expand Down Expand Up @@ -60,7 +61,7 @@ trait Script {
*/
def statements: Seq[String] = {
// Regex matches on semicolons that neither precede nor follow other semicolons
sql.split("(?<!;);(?!;)").map(_.trim.replace(";;", ";")).filter(_ != "")
ArraySeq.unsafeWrapArray(sql.split("(?<!;);(?!;)")).map(_.trim.replace(";;", ";")).filter(_ != "")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ private[server] class AkkaModelConversion(
override def clientCertificateChain: Option[Seq[X509Certificate]] = {
try {
request.header[`Tls-Session-Info`].map { tlsSessionInfo =>
tlsSessionInfo.getSession.getPeerCertificates
immutable.ArraySeq
.unsafeWrapArray(tlsSessionInfo.getSession.getPeerCertificates)
.collect { case x509: X509Certificate => x509 }
}
} catch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object ProdServerStart {
/**
* Start a prod mode server from the command line.
*/
def main(args: Array[String]): Unit = start(new RealServerProcess(args))
def main(args: Array[String]): Unit = start(new RealServerProcess(args.toIndexedSeq))

/**
* Starts a Play server and application for the given process. The settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import play.core.utils.AsciiRange
import play.core.utils.AsciiSet

import scala.annotation.tailrec
import scala.collection.immutable.ArraySeq
import scala.concurrent.Future
import scala.util.control.NonFatal

Expand Down Expand Up @@ -334,5 +335,5 @@ private[play] final class ServerResultUtils(
}

def splitSetCookieHeaderValue(value: String): Seq[String] =
cookieHeaderEncoding.SetCookieHeaderSeparatorRegex.split(value)
ArraySeq.unsafeWrapArray(cookieHeaderEncoding.SetCookieHeaderSeparatorRegex.split(value))
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import play.core.j.JavaContextComponents
import play.core.j.JavaHttpErrorHandlerAdapter

import scala.concurrent.Future
import scala.jdk.CollectionConverters._
import play.api.Logger
import play.api.libs.streams.Accumulator
import play.api.libs.typedmap.TypedKey
Expand Down Expand Up @@ -56,7 +57,7 @@ class CORSFilter(
this(
corsConfig,
new JavaHttpErrorHandlerAdapter(errorHandler),
Seq(pathPrefixes.toArray.asInstanceOf[Array[String]]: _*)
pathPrefixes.asScala.toSeq
)
}

Expand All @@ -70,7 +71,7 @@ class CORSFilter(
this(
corsConfig,
new JavaHttpErrorHandlerAdapter(errorHandler),
Seq(pathPrefixes.toArray.asInstanceOf[Array[String]]: _*)
pathPrefixes.asScala.toSeq
)
}

Expand Down

0 comments on commit 6c6480c

Please sign in to comment.