Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up eliminate warnings tackle deprecations #11001

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static Binder binder(Object module) {
if (module instanceof AbstractModule) {
try {
Method method = AbstractModule.class.getDeclaredMethod("binder");
if (!method.isAccessible()) {
if (!method.canAccess(module)) {
method.setAccessible(true);
}
return (Binder) method.invoke(module);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ 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.jdk.CollectionConverters._
val injectorModule = GuiceableModule.guice(
Seq(
bind[GuiceInjector].toSelf,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ trait AkkaGuiceSupport {

private def accessBinder: Binder = {
val method: Method = classOf[AbstractModule].getDeclaredMethod("binder")
if (!method.isAccessible) {
if (!method.canAccess(this)) {
method.setAccessible(true)
}
method.invoke(this).asInstanceOf[Binder]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class JavaRequestsSpec extends PlaySpecification {
}

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,6 @@ 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.jdk.CollectionConverters._
val cookies = result.cookies().iterator().asScala.toList
val cookieValues = cookies.map(_.value)
cookieValues must not contain "KitKat"
Expand Down Expand Up @@ -544,7 +543,6 @@ trait JavaResultsHandlingSpec

"chunk comet results from string" in makeRequest(new MockController {
def action(request: Http.Request) = {
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
3 changes: 1 addition & 2 deletions core/play/src/main/scala/play/core/j/JavaResults.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
package play.core.j

import scala.annotation.varargs
import scala.jdk.CollectionConverters
import scala.language.reflectiveCalls

import play.mvc.{ ResponseHeader => JResponseHeader }

object JavaResultExtractor {
@varargs
def withHeader(responseHeader: JResponseHeader, nameValues: String*): JResponseHeader = {
import CollectionConverters._
import scala.jdk.CollectionConverters._
if (nameValues.length % 2 != 0) {
throw new IllegalArgumentException(
"Unmatched name - withHeaders must be invoked with an even number of string arguments"
Expand Down
10 changes: 5 additions & 5 deletions core/play/src/test/scala/play/api/i18n/MessagesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ class MessagesSpec extends Specification {
val testMessageFile = """
# this is a comment
simplekey=value
key.with.dots=value
key.with.dollar$sign=value
key.with.dots=value1
key.with.dollar$sign=value2
multiline.unix=line1\
line2
multiline.dos=line1\
Expand All @@ -166,13 +166,13 @@ backslash.dummy=\a\b\c\e\f

"MessagesPlugin" should {
"parse file" in {
val parser = new Messages.MessagesParser(new MessageSource { def read = testMessageFile }, "messages")
val parser = new Messages.MessagesParser(new MessageSource { def read: String = testMessageFile }, "messages")

val messages = parser.parse.toSeq.flatten[Messages.Message].map(x => x.key -> x.pattern).toMap

messages("simplekey") must ===("value")
messages("key.with.dots") must ===("value")
messages("key.with.dollar$sign") must ===("value")
messages("key.with.dots") must ===("value1")
messages("key.with.dollar$sign") must ===("value2")
messages("multiline.unix") must ===("line1line2")
messages("multiline.dos") must ===("line1line2")
messages("multiline.inline") must ===("line1\nline2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ class TemporaryFileReaperSpec(implicit ee: ExecutionEnv) extends Specification w
val config = TemporaryFileReaperConfiguration(
enabled = false,
olderThan = 1.seconds,
initialDelay = 0 seconds,
interval = 100 millis
initialDelay = 0.seconds,
interval = 100.millis
)

val file = parentDirectory.resolve("notcollected.txt")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,6 @@ class DatabasesSpec extends Specification {

trait WithDatabase extends After {
def db: Database
def after = () // db.shutdown()
def after: Unit = () // db.shutdown()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private[server] object PathAndQueryParser {
try {
new URI(unsafePath).getRawPath
} catch {
case _ =>
case _: Throwable =>
// If the URI has an invalid path, this will trigger a 400 (bad request) error.
// Also it's probably a good idea to throw our own IllegalStateException were we have
// control over the message that will be passed to the error handler instead of just passing on the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ object WebSocketFlowHandler {
setHandler(
appOut,
new OutHandler {
override def onPull() = {
override def onPull(): Unit = {
// We always pull from the remote in when the app pulls, even if closing, since if we get a message from
// the client and we're still open, we still want to send it.
if (!hasBeenPulled(remoteIn)) {
pull(remoteIn)
}
}

override def onDownstreamFinish() = {
override def onDownstreamFinish(cause: Throwable): Unit = {
if (state == Open) {
serverInitiatedClose(CloseMessage(Some(CloseCodes.Regular)))
}
Expand Down