Skip to content

Commit 64b1f66

Browse files
committed
clear warnings in http-core
1 parent b99f368 commit 64b1f66

File tree

18 files changed

+31
-42
lines changed

18 files changed

+31
-42
lines changed

http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ private[http] object Http2 extends ExtensionId[Http2Ext] with ExtensionIdProvide
293293
override def get(system: ClassicActorSystemProvider): Http2Ext = super.get(system)
294294
def apply()(implicit system: ClassicActorSystemProvider): Http2Ext = super.apply(system)
295295
override def apply(system: ActorSystem): Http2Ext = super.apply(system)
296-
def lookup(): ExtensionId[_ <: Extension] = Http2
296+
def lookup: ExtensionId[_ <: Extension] = Http2
297297
def createExtension(system: ExtendedActorSystem): Http2Ext = new Http2Ext()(system)
298298

299299
private[http] type HttpImplementation = Flow[SslTlsInbound, SslTlsOutbound, ServerTerminator]

http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/BodyPartRenderer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private[http] object BodyPartRenderer {
151151
def randomBoundary(length: Int = 18, random: java.util.Random = ThreadLocalRandom.current()): String = {
152152
val array = new Array[Byte](length)
153153
random.nextBytes(array)
154-
Base64.custom.encodeToString(array, false)
154+
Base64.custom().encodeToString(array, false)
155155
}
156156

157157
/**

http-core/src/main/scala/org/apache/pekko/http/impl/engine/rendering/RenderSupport.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ private[http] object RenderSupport {
5656
val defaultLastChunkBytes: ByteString = renderChunk(HttpEntity.LastChunk)
5757

5858
def CancelSecond[T, Mat](first: Source[T, Mat], second: Source[T, Any]): Source[T, Mat] = {
59-
Source.fromGraph(GraphDSL.create(first) { implicit b => frst =>
59+
Source.fromGraph(GraphDSL.createGraph(first) { implicit b => frst =>
6060
import GraphDSL.Implicits._
6161
second ~> Sink.cancelled
6262
SourceShape(frst.out)

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

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

16-
import org.apache.pekko
1716
import org.parboiled2.CharPredicate
1817

1918
// efficient encoding of *7-bit* ASCII characters

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import pekko.stream.scaladsl.Keep
4343
object Http extends ExtensionId[Http] with ExtensionIdProvider {
4444
override def get(system: ActorSystem): Http = super.get(system)
4545
override def get(system: ClassicActorSystemProvider): Http = super.get(system)
46-
def lookup() = Http
46+
def lookup = Http
4747
def createExtension(system: ExtendedActorSystem): Http = new Http(system)
4848
}
4949

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ import pekko.http.impl.util.JavaMapping.Implicits._
2727
import scala.annotation.varargs
2828
import scala.collection.JavaConverters._
2929
import pekko.http.javadsl.model.{ HttpMethod, MediaType, StatusCode, Uri }
30-
import scala.annotation.nowarn
3130
import com.typesafe.config.Config
3231

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

144142
def forServer(system: ClassicActorSystemProvider): ParserSettings =

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme
189189
@deprecated(
190190
"Use Http().newServerAt(...)...connectionSource() to create a source that can be materialized to a binding.",
191191
since = "10.2.0")
192-
@nowarn("msg=deprecated")
193192
def bind(interface: String, port: Int = DefaultPortForProtocol,
194193
connectionContext: ConnectionContext = defaultServerHttpContext,
195194
settings: ServerSettings = ServerSettings(system),
@@ -238,7 +237,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme
238237
* use the `pekko.http.server` config section or pass in a [[pekko.http.scaladsl.settings.ServerSettings]] explicitly.
239238
*/
240239
@deprecated("Use Http().newServerAt(...)...bindFlow() to create server bindings.", since = "10.2.0")
241-
@nowarn("msg=deprecated")
242240
def bindAndHandle(
243241
handler: Flow[HttpRequest, HttpResponse, Any],
244242
interface: String, port: Int = DefaultPortForProtocol,
@@ -320,7 +318,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme
320318
* use the `pekko.http.server` config section or pass in a [[pekko.http.scaladsl.settings.ServerSettings]] explicitly.
321319
*/
322320
@deprecated("Use Http().newServerAt(...)...bindSync() to create server bindings.", since = "10.2.0")
323-
@nowarn("msg=deprecated")
324321
def bindAndHandleSync(
325322
handler: HttpRequest => HttpResponse,
326323
interface: String, port: Int = DefaultPortForProtocol,
@@ -349,7 +346,6 @@ class HttpExt @InternalStableApi /* constructor signature is hardcoded in Teleme
349346
* Any other value for `parallelism` overrides the setting.
350347
*/
351348
@deprecated("Use Http().newServerAt(...)...bind() to create server bindings.", since = "10.2.0")
352-
@nowarn("msg=deprecated")
353349
def bindAndHandleAsync(
354350
handler: HttpRequest => Future[HttpResponse],
355351
interface: String, port: Int = DefaultPortForProtocol,
@@ -1133,7 +1129,7 @@ object Http extends ExtensionId[HttpExt] with ExtensionIdProvider {
11331129
def apply()(implicit system: ClassicActorSystemProvider): HttpExt = super.apply(system)
11341130
override def apply(system: ActorSystem): HttpExt = super.apply(system)
11351131

1136-
def lookup() = Http
1132+
def lookup = Http
11371133

11381134
def createExtension(system: ExtendedActorSystem): HttpExt =
11391135
new HttpExt(system.settings.config.getConfig("pekko.http"))(system)

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@
1414
package org.apache.pekko.http.scaladsl.model
1515

1616
import java.util.OptionalLong
17-
1817
import language.implicitConversions
1918
import java.io.File
20-
import java.nio.file.{ Files, Path }
21-
import java.lang.{ Iterable => JIterable }
22-
19+
import java.nio.file.{Files, Path}
20+
import java.lang.{Iterable => JIterable}
2321
import scala.util.control.NonFatal
2422
import scala.concurrent.Future
2523
import scala.concurrent.duration._
@@ -29,19 +27,19 @@ import pekko.util.ByteString
2927
import pekko.stream.scaladsl._
3028
import pekko.stream.stage._
3129
import pekko.stream._
32-
import pekko.{ stream, Done, NotUsed }
30+
import pekko.{Done, NotUsed, stream}
3331
import pekko.http.scaladsl.util.FastFuture
34-
import pekko.http.javadsl.{ model => jm }
35-
import pekko.http.impl.util.{ JavaMapping, StreamUtils }
32+
import pekko.http.javadsl.{model => jm}
33+
import pekko.http.impl.util.{JavaMapping, StreamUtils}
3634
import pekko.http.impl.util.JavaMapping.Implicits._
3735

3836
import scala.compat.java8.OptionConverters._
3937
import scala.compat.java8.FutureConverters._
4038
import java.util.concurrent.CompletionStage
41-
4239
import pekko.actor.ClassicActorSystemProvider
43-
import pekko.annotation.{ DoNotInherit, InternalApi }
40+
import pekko.annotation.{DoNotInherit, InternalApi}
4441

42+
import scala.annotation.nowarn
4543
import scala.compat.java8.FutureConverters
4644

4745
/**
@@ -664,6 +662,7 @@ object HttpEntity {
664662
private var maxBytes = -1L
665663
private var bytesLeft = Long.MaxValue
666664

665+
@nowarn("msg=getFirst in class Attributes is deprecated") // there's no valid alternative right now
667666
override def preStart(): Unit = {
668667
attributes.getFirst[SizeLimit] match {
669668
case Some(limit: SizeLimit) if limit.isDisabled =>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ final case class BasicHttpCredentials(username: String, password: String) extend
3333
val cookie = {
3434
val userPass = username + ':' + password
3535
val bytes = userPass.getBytes(`UTF-8`.nioCharset)
36-
Base64.rfc2045.encodeToChar(bytes, false)
36+
Base64.rfc2045().encodeToChar(bytes, false)
3737
}
3838
def render[R <: Rendering](r: R): r.type = r ~~ "Basic " ~~ cookie
3939

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

4545
object BasicHttpCredentials {
4646
def apply(credentials: String): BasicHttpCredentials = {
47-
val bytes = Base64.rfc2045.decodeFast(credentials.toCharArray)
47+
val bytes = Base64.rfc2045().decodeFast(credentials.toCharArray)
4848
val userPass = new String(bytes, `UTF-8`.nioCharset)
4949
userPass.indexOf(':') match {
5050
case -1 => apply(userPass, "")

http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/HostConnectionPoolSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ class HostConnectionPoolSpec extends PekkoSpecWithMaterializer(
886886
// 2. when client connection was established, grab server connection as well and attach to proxies
887887
// (cannot be implemented with just mapMaterializedValue because there's no transposing constructor for BidiFlow)
888888
BidiFlow.fromGraph(
889-
GraphDSL.create(Sink.asPublisher[HttpResponse](fanout = false), Source.asSubscriber[HttpRequest],
889+
GraphDSL.createGraph(Sink.asPublisher[HttpResponse](fanout = false), Source.asSubscriber[HttpRequest],
890890
clientConnectionFlow(serverBinding, connectionKillSwitch))((_, _, _)) {
891891
implicit builder => (resIn, reqOut, client) =>
892892
import GraphDSL.Implicits._

http-core/src/test/scala/org/apache/pekko/http/impl/engine/client/LowLevelOutgoingConnectionSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ class LowLevelOutgoingConnectionSpec extends PekkoSpecWithMaterializer with Insi
10221022
val netOut = TestSubscriber.manualProbe[ByteString]()
10231023
val netIn = TestPublisher.manualProbe[ByteString]()
10241024

1025-
RunnableGraph.fromGraph(GraphDSL.create(OutgoingConnectionBlueprint(Host("example.com"), settings, NoLogging)) {
1025+
RunnableGraph.fromGraph(GraphDSL.createGraph(OutgoingConnectionBlueprint(Host("example.com"), settings, NoLogging)) {
10261026
implicit b => client =>
10271027
import GraphDSL.Implicits._
10281028
Source.fromPublisher(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> client.in2

http-core/src/test/scala/org/apache/pekko/http/impl/engine/server/HttpServerTestSetupBase.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ abstract class HttpServerTestSetupBase {
4646
val netIn = TestPublisher.probe[ByteString]()
4747
val netOut = ByteStringSinkProbe()
4848

49-
RunnableGraph.fromGraph(GraphDSL.create(modifyServer(Http().serverLayer(settings))) { implicit b => server =>
49+
RunnableGraph.fromGraph(GraphDSL.createGraph(modifyServer(Http().serverLayer(settings))) { implicit b => server =>
5050
import GraphDSL.Implicits._
5151
Source.fromPublisher(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> server.in2
5252
server.out1 ~> Flow[SslTlsOutbound].collect { case SendBytes(x) => x }.buffer(1,

http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/ByteStringSinkProbe.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private[http] object ByteStringSinkProbe {
6464
}
6565
def expectNoBytes(): Unit = {
6666
ensureRequested()
67-
probe.expectNoMsg()
67+
probe.expectNoMessage()
6868
}
6969
def expectNoBytes(timeout: FiniteDuration): Unit = {
7070
ensureRequested()

http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WSClientAutobahnTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object WSClientAutobahnTest extends App {
5050
s"ws://localhost:9001/updateReports?agent=$agent"
5151

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

http-core/src/test/scala/org/apache/pekko/http/impl/engine/ws/WebSocketClientSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ class WebSocketClientSpec extends PekkoSpecWithMaterializer("pekko.http.client.w
373373
val netIn = TestPublisher.probe[ByteString]()
374374

375375
val graph =
376-
RunnableGraph.fromGraph(GraphDSL.create(clientLayer) { implicit b => client =>
376+
RunnableGraph.fromGraph(GraphDSL.createGraph(clientLayer) { implicit b => client =>
377377
import GraphDSL.Implicits._
378378
Source.fromPublisher(netIn) ~> Flow[ByteString].map(SessionBytes(null, _)) ~> client.in2
379379
client.out1 ~> Flow[SslTlsOutbound].collect { case SendBytes(x) => x } ~> netOut.sink

http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313

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

16+
import org.scalatest.exceptions.TestFailedException
17+
import org.scalatest.freespec.AnyFreeSpec
18+
import org.scalatest.matchers.should.Matchers
19+
import org.scalatest.matchers.{ MatchResult, Matcher }
20+
1621
import org.apache.pekko
1722
import pekko.http.scaladsl.settings.ParserSettings.CookieParsingMode
1823
import pekko.http.impl.model.parser.HeaderParser.Settings
19-
import org.scalatest.matchers.{ MatchResult, Matcher }
2024
import pekko.http.impl.util._
2125
import pekko.http.scaladsl.model.{ HttpHeader, _ }
2226
import headers._
@@ -29,9 +33,6 @@ import HttpMethods._
2933

3034
import java.net.InetAddress
3135
import pekko.http.scaladsl.model.MediaType.WithOpenCharset
32-
import org.scalatest.exceptions.TestFailedException
33-
import org.scalatest.freespec.AnyFreeSpec
34-
import org.scalatest.matchers.should.Matchers
3536

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

6263
"Accept-Charset" in {

http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ConnectionPoolSettingsSpec.scala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

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

16-
import scala.util.Failure
17-
import scala.util.Success
18-
import scala.util.Try
1916
import org.apache.pekko
2017
import pekko.testkit.PekkoSpec
2118
import pekko.http.scaladsl.model.headers.`User-Agent`
@@ -161,11 +158,6 @@ class ConnectionPoolSettingsSpec extends PekkoSpec {
161158
settings.forHost("akka.com").minConnections shouldEqual 2
162159
settings.minConnections shouldEqual 2
163160
}
164-
165-
def expectError(configString: String): String = Try(config(configString)) match {
166-
case Failure(cause) => cause.getMessage
167-
case Success(_) => fail("Expected a failure when max-open-requests is not a power of 2")
168-
}
169161
}
170162

171163
def config(configString: String): ConnectionPoolSettings =

project/Common.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@ object Common extends AutoPlugin {
4545
(if (isJdk8) Seq.empty
4646
else if (scalaBinaryVersion.value == "2.12") Seq("-target:jvm-1.8")
4747
else Seq("-release", "8")),
48+
Test / scalacOptions ++=Seq(
49+
// we sometimes use pattern definitions in tests just for the side-effects and don't care about the extra member
50+
"-Wconf:msg=Pattern definition introduces Unit-valued member:s",
51+
),
4852
javacOptions ++=
4953
Seq("-encoding", "UTF-8") ++ onlyOnJdk8("-source", "1.8") ++ onlyAfterJdk8("--release", "8"),
5054
// restrict to 'compile' scope because otherwise it is also passed to

0 commit comments

Comments
 (0)