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

clear warnings in http-core #115

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ private[http] object Http2 extends ExtensionId[Http2Ext] with ExtensionIdProvide
override def get(system: ClassicActorSystemProvider): Http2Ext = super.get(system)
def apply()(implicit system: ClassicActorSystemProvider): Http2Ext = super.apply(system)
override def apply(system: ActorSystem): Http2Ext = super.apply(system)
def lookup(): ExtensionId[_ <: Extension] = Http2
def lookup: ExtensionId[_ <: Extension] = Http2
def createExtension(system: ExtendedActorSystem): Http2Ext = new Http2Ext()(system)

private[http] type HttpImplementation = Flow[SslTlsInbound, SslTlsOutbound, ServerTerminator]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private[http] object BodyPartRenderer {
def randomBoundary(length: Int = 18, random: java.util.Random = ThreadLocalRandom.current()): String = {
val array = new Array[Byte](length)
random.nextBytes(array)
Base64.custom.encodeToString(array, false)
Base64.custom().encodeToString(array, false)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private[http] object RenderSupport {
val defaultLastChunkBytes: ByteString = renderChunk(HttpEntity.LastChunk)

def CancelSecond[T, Mat](first: Source[T, Mat], second: Source[T, Any]): Source[T, Mat] = {
Source.fromGraph(GraphDSL.create(first) { implicit b => frst =>
Source.fromGraph(GraphDSL.createGraph(first) { implicit b => frst =>
import GraphDSL.Implicits._
second ~> Sink.cancelled
SourceShape(frst.out)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

package org.apache.pekko.http.impl.model.parser

import org.apache.pekko
import org.parboiled2.CharPredicate

// efficient encoding of *7-bit* ASCII characters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import pekko.stream.scaladsl.Keep
object Http extends ExtensionId[Http] with ExtensionIdProvider {
override def get(system: ActorSystem): Http = super.get(system)
override def get(system: ClassicActorSystemProvider): Http = super.get(system)
def lookup() = Http
def lookup = Http
def createExtension(system: ExtendedActorSystem): Http = new Http(system)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import pekko.http.impl.util.JavaMapping.Implicits._
import scala.annotation.varargs
import scala.collection.JavaConverters._
import pekko.http.javadsl.model.{ HttpMethod, MediaType, StatusCode, Uri }
import scala.annotation.nowarn
import com.typesafe.config.Config

/**
Expand Down Expand Up @@ -138,7 +137,6 @@ object ParserSettings extends SettingsCompanion[ParserSettings] {
*/
@Deprecated
@deprecated("Use forServer or forClient instead", since = "Akka HTTP 10.2.0")
@nowarn("msg=create overrides concrete, non-deprecated symbol")
override def create(system: ActorSystem): ParserSettings = create(system.settings.config)

def forServer(system: ClassicActorSystemProvider): ParserSettings =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme
@deprecated(
"Use Http().newServerAt(...)...connectionSource() to create a source that can be materialized to a binding.",
since = "10.2.0")
@nowarn("msg=deprecated")
def bind(interface: String, port: Int = DefaultPortForProtocol,
connectionContext: ConnectionContext = defaultServerHttpContext,
settings: ServerSettings = ServerSettings(system),
Expand Down Expand Up @@ -238,7 +237,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme
* use the `pekko.http.server` config section or pass in a [[pekko.http.scaladsl.settings.ServerSettings]] explicitly.
*/
@deprecated("Use Http().newServerAt(...)...bindFlow() to create server bindings.", since = "10.2.0")
@nowarn("msg=deprecated")
def bindAndHandle(
handler: Flow[HttpRequest, HttpResponse, Any],
interface: String, port: Int = DefaultPortForProtocol,
Expand Down Expand Up @@ -320,7 +318,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme
* use the `pekko.http.server` config section or pass in a [[pekko.http.scaladsl.settings.ServerSettings]] explicitly.
*/
@deprecated("Use Http().newServerAt(...)...bindSync() to create server bindings.", since = "10.2.0")
@nowarn("msg=deprecated")
def bindAndHandleSync(
handler: HttpRequest => HttpResponse,
interface: String, port: Int = DefaultPortForProtocol,
Expand Down Expand Up @@ -349,7 +346,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme
* Any other value for `parallelism` overrides the setting.
*/
@deprecated("Use Http().newServerAt(...)...bind() to create server bindings.", since = "10.2.0")
@nowarn("msg=deprecated")
def bindAndHandleAsync(
handler: HttpRequest => Future[HttpResponse],
interface: String, port: Int = DefaultPortForProtocol,
Expand Down Expand Up @@ -1133,7 +1129,7 @@ object Http extends ExtensionId[HttpExt] with ExtensionIdProvider {
def apply()(implicit system: ClassicActorSystemProvider): HttpExt = super.apply(system)
override def apply(system: ActorSystem): HttpExt = super.apply(system)

def lookup() = Http
def lookup = Http

def createExtension(system: ExtendedActorSystem): HttpExt =
new HttpExt(system.settings.config.getConfig("pekko.http"))(system)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
package org.apache.pekko.http.scaladsl.model

import java.util.OptionalLong

import language.implicitConversions
import java.io.File
import java.nio.file.{ Files, Path }
import java.lang.{ Iterable => JIterable }

import scala.util.control.NonFatal
import scala.concurrent.Future
import scala.concurrent.duration._
Expand All @@ -38,10 +36,10 @@ import pekko.http.impl.util.JavaMapping.Implicits._
import scala.compat.java8.OptionConverters._
import scala.compat.java8.FutureConverters._
import java.util.concurrent.CompletionStage

import pekko.actor.ClassicActorSystemProvider
import pekko.annotation.{ DoNotInherit, InternalApi }

import scala.annotation.nowarn
import scala.compat.java8.FutureConverters

/**
Expand Down Expand Up @@ -664,6 +662,7 @@ object HttpEntity {
private var maxBytes = -1L
private var bytesLeft = Long.MaxValue

@nowarn("msg=getFirst in class Attributes is deprecated") // there's no valid alternative right now
override def preStart(): Unit = {
attributes.getFirst[SizeLimit] match {
case Some(limit: SizeLimit) if limit.isDisabled =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final case class BasicHttpCredentials(username: String, password: String) extend
val cookie = {
val userPass = username + ':' + password
val bytes = userPass.getBytes(`UTF-8`.nioCharset)
Base64.rfc2045.encodeToChar(bytes, false)
Base64.rfc2045().encodeToChar(bytes, false)
}
def render[R <: Rendering](r: R): r.type = r ~~ "Basic " ~~ cookie

Expand All @@ -44,7 +44,7 @@ final case class BasicHttpCredentials(username: String, password: String) extend

object BasicHttpCredentials {
def apply(credentials: String): BasicHttpCredentials = {
val bytes = Base64.rfc2045.decodeFast(credentials.toCharArray)
val bytes = Base64.rfc2045().decodeFast(credentials.toCharArray)
val userPass = new String(bytes, `UTF-8`.nioCharset)
userPass.indexOf(':') match {
case -1 => apply(userPass, "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ class HostConnectionPoolSpec extends PekkoSpecWithMaterializer(
// 2. when client connection was established, grab server connection as well and attach to proxies
// (cannot be implemented with just mapMaterializedValue because there's no transposing constructor for BidiFlow)
BidiFlow.fromGraph(
GraphDSL.create(Sink.asPublisher[HttpResponse](fanout = false), Source.asSubscriber[HttpRequest],
GraphDSL.createGraph(Sink.asPublisher[HttpResponse](fanout = false), Source.asSubscriber[HttpRequest],
clientConnectionFlow(serverBinding, connectionKillSwitch))((_, _, _)) {
implicit builder => (resIn, reqOut, client) =>
import GraphDSL.Implicits._
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1022,7 +1022,8 @@ class LowLevelOutgoingConnectionSpec extends PekkoSpecWithMaterializer with Insi
val netOut = TestSubscriber.manualProbe[ByteString]()
val netIn = TestPublisher.manualProbe[ByteString]()

RunnableGraph.fromGraph(GraphDSL.create(OutgoingConnectionBlueprint(Host("example.com"), settings, NoLogging)) {
RunnableGraph.fromGraph(GraphDSL.createGraph(OutgoingConnectionBlueprint(Host("example.com"), settings,
NoLogging)) {
implicit b => client =>
import GraphDSL.Implicits._
Source.fromPublisher(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> client.in2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ abstract class HttpServerTestSetupBase {
val netIn = TestPublisher.probe[ByteString]()
val netOut = ByteStringSinkProbe()

RunnableGraph.fromGraph(GraphDSL.create(modifyServer(Http().serverLayer(settings))) { implicit b => server =>
RunnableGraph.fromGraph(GraphDSL.createGraph(modifyServer(Http().serverLayer(settings))) { implicit b => server =>
import GraphDSL.Implicits._
Source.fromPublisher(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> server.in2
server.out1 ~> Flow[SslTlsOutbound].collect { case SendBytes(x) => x }.buffer(1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private[http] object ByteStringSinkProbe {
}
def expectNoBytes(): Unit = {
ensureRequested()
probe.expectNoMsg()
probe.expectNoMessage()
}
def expectNoBytes(timeout: FiniteDuration): Unit = {
ensureRequested()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object WSClientAutobahnTest extends App {
s"ws://localhost:9001/updateReports?agent=$agent"

def runCase(caseIndex: Int, agent: String = Agent): Future[CaseStatus] =
runWs(runCaseUri(caseIndex, agent), echo).recover { case _ => () }.flatMap { _ =>
runWs(runCaseUri(caseIndex, agent), echo).recover { case _ => (): Any }.flatMap { _ =>
getCaseStatus(caseIndex, agent)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ class WebSocketClientSpec extends PekkoSpecWithMaterializer("pekko.http.client.w
val netIn = TestPublisher.probe[ByteString]()

val graph =
RunnableGraph.fromGraph(GraphDSL.create(clientLayer) { implicit b => client =>
RunnableGraph.fromGraph(GraphDSL.createGraph(clientLayer) { implicit b => client =>
import GraphDSL.Implicits._
Source.fromPublisher(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> client.in2
client.out1 ~> Flow[SslTlsOutbound].collect { case SendBytes(x) => x } ~> netOut.sink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@

package org.apache.pekko.http.impl.model.parser

import org.scalatest.exceptions.TestFailedException
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers
import org.scalatest.matchers.{ MatchResult, Matcher }

import org.apache.pekko
import pekko.http.scaladsl.settings.ParserSettings.CookieParsingMode
import pekko.http.impl.model.parser.HeaderParser.Settings
import org.scalatest.matchers.{ MatchResult, Matcher }
import pekko.http.impl.util._
import pekko.http.scaladsl.model.{ HttpHeader, _ }
import headers._
Expand All @@ -29,9 +33,6 @@ import HttpMethods._

import java.net.InetAddress
import pekko.http.scaladsl.model.MediaType.WithOpenCharset
import org.scalatest.exceptions.TestFailedException
import org.scalatest.freespec.AnyFreeSpec
import org.scalatest.matchers.should.Matchers

class HttpHeaderSpec extends AnyFreeSpec with Matchers {
val `application/vnd.spray` = MediaType.applicationBinary("vnd.spray", MediaType.Compressible)
Expand All @@ -56,7 +57,8 @@ class HttpHeaderSpec extends AnyFreeSpec with Matchers {
MediaRange.custom("text", Map("foo" -> "bar")),
MediaType.customBinary("custom", "custom", MediaType.Compressible, params = Map("bar" -> "b>az")))
"Accept: application/*+xml; version=2" =!=
Accept(MediaType.customBinary("application", "*+xml", MediaType.Compressible, params = Map("version" -> "2")))
Accept(MediaType.customBinary("application", "*+xml", MediaType.Compressible,
params = Map("version" -> "2")): MediaRange)
}

"Accept-Charset" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@

package org.apache.pekko.http.scaladsl.settings

import scala.util.Failure
import scala.util.Success
import scala.util.Try
import org.apache.pekko
import pekko.testkit.PekkoSpec
import pekko.http.scaladsl.model.headers.`User-Agent`
Expand Down Expand Up @@ -161,11 +158,6 @@ class ConnectionPoolSettingsSpec extends PekkoSpec {
settings.forHost("akka.com").minConnections shouldEqual 2
settings.minConnections shouldEqual 2
}

def expectError(configString: String): String = Try(config(configString)) match {
case Failure(cause) => cause.getMessage
case Success(_) => fail("Expected a failure when max-open-requests is not a power of 2")
}
}

def config(configString: String): ConnectionPoolSettings =
Expand Down
3 changes: 3 additions & 0 deletions project/Common.scala
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ object Common extends AutoPlugin {
(if (isJdk8) Seq.empty
else if (scalaBinaryVersion.value == "2.12") Seq("-target:jvm-1.8")
else Seq("-release", "8")),
Test / scalacOptions ++= Seq(
// we sometimes use pattern definitions in tests just for the side-effects and don't care about the extra member
"-Wconf:msg=Pattern definition introduces Unit-valued member:s"),
javacOptions ++=
Seq("-encoding", "UTF-8") ++ onlyOnJdk8("-source", "1.8") ++ onlyAfterJdk8("--release", "8"),
// restrict to 'compile' scope because otherwise it is also passed to
Expand Down