This is an automated email from the ASF dual-hosted git repository.
fanningpj pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-http.git
The following commit(s) were added to refs/heads/main by this push:
new dd399deff reduce number of silenced compiler warnings (#810)
dd399deff is described below
commit dd399deff2aa249e3598765cc25b43934c52107c
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Oct 2 08:15:09 2025 +0100
reduce number of silenced compiler warnings (#810)
* reduce number of silenced compiler warnings
* fix more warnings
* fix more warnings
* more warnings
* fix more warnings
* Update UriJavaAccessor.scala
---
.../apache/pekko/http/impl/engine/client/PoolInterface.scala | 2 +-
.../pekko/http/impl/engine/client/PoolMasterActor.scala | 4 ++--
.../pekko/http/impl/engine/http2/Http2Multiplexer.scala | 1 -
.../http/impl/engine/http2/client/ResponseParsing.scala | 2 +-
.../http/impl/engine/http2/hpack/Http2HeaderParsing.scala | 2 +-
.../pekko/http/impl/engine/parsing/HttpHeaderParser.scala | 1 -
.../http/impl/util/EnhancedByteStringTraversableOnce.scala | 2 +-
.../org/apache/pekko/http/impl/util/EnhancedString.scala | 8 ++++----
.../main/scala/org/apache/pekko/http/impl/util/package.scala | 2 +-
.../http/javadsl/settings/ClientConnectionSettings.scala | 12 ++++++------
.../apache/pekko/http/javadsl/settings/ServerSettings.scala | 2 +-
.../src/main/scala/org/apache/pekko/http/scaladsl/Http.scala | 2 --
.../org/apache/pekko/http/scaladsl/model/ContentType.scala | 2 +-
.../org/apache/pekko/http/scaladsl/model/MediaType.scala | 2 +-
.../pekko/http/scaladsl/model/headers/HttpChallenge.scala | 2 +-
.../pekko/http/scaladsl/model/headers/HttpCookie.scala | 6 +++---
.../pekko/http/scaladsl/model/headers/LanguageRange.scala | 3 ++-
.../test/scala/org/apache/pekko/http/HashCodeCollider.scala | 4 ++--
.../pekko/http/impl/engine/parsing/BoyerMooreSpec.scala | 2 +-
.../pekko/http/impl/engine/parsing/ResponseParserSpec.scala | 2 +-
.../apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala | 1 -
.../org/apache/pekko/http/impl/util/WithLogCapturing.scala | 4 ++--
.../org/apache/pekko/http/scaladsl/model/DateTimeSpec.scala | 2 +-
.../test/scala/org/apache/pekko/http/HashCodeCollider.scala | 4 ++--
.../org/apache/pekko/http/scaladsl/coding/CoderSpec.scala | 2 +-
.../server/DiscardEntityDefaultExceptionHandlerSpec.scala | 2 +-
.../server/DiscardEntityDefaultRejectionHandlerSpec.scala | 2 +-
.../org/apache/pekko/http/javadsl/server/Rejections.scala | 2 +-
.../http/javadsl/server/directives/FormFieldDirectives.scala | 4 ++--
.../http/javadsl/server/directives/ParameterDirectives.scala | 2 +-
.../pekko/http/scaladsl/unmarshalling/Unmarshaller.scala | 2 +-
project/Common.scala | 7 -------
32 files changed, 43 insertions(+), 54 deletions(-)
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolInterface.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolInterface.scala
index 9b6d30be1..dfd3811af 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolInterface.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolInterface.scala
@@ -225,7 +225,7 @@ private[http] object PoolInterface {
requestCallback.invokeWithFeedback((request,
responsePromise)).failed.foreach { _ =>
debug(
"Request was sent to pool which was already closed, retrying through
the master to create new pool instance")
- responsePromise.tryCompleteWith(master.dispatchRequest(poolId,
request)(materializer))
+ responsePromise.completeWith(master.dispatchRequest(poolId,
request)(materializer))
}
override def shutdown()(implicit ec: ExecutionContext):
Future[ShutdownReason] = {
shutdownCallback.invoke(())
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolMasterActor.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolMasterActor.scala
index 401f66edc..86e4e6729 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolMasterActor.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/client/PoolMasterActor.scala
@@ -187,12 +187,12 @@ private[http] final class PoolMasterActor extends Actor
with ActorLogging {
// to this actor by the pool actor, they will be retried once the
shutdown
// has completed.
val completed = pool.shutdown()(context.dispatcher)
- shutdownCompletedPromise.tryCompleteWith(
+ shutdownCompletedPromise.completeWith(
completed.map(_ => Done)(ExecutionContext.parasitic))
statusById += poolId ->
PoolInterfaceShuttingDown(shutdownCompletedPromise)
case Some(PoolInterfaceShuttingDown(formerPromise)) =>
// Pool is already shutting down, mirror the existing promise.
- shutdownCompletedPromise.tryCompleteWith(formerPromise.future)
+ shutdownCompletedPromise.completeWith(formerPromise.future)
case None =>
// Pool does not exist, shutdown is not needed.
shutdownCompletedPromise.trySuccess(Done)
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Multiplexer.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Multiplexer.scala
index cd6e6a5ce..3a7f77b3e 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Multiplexer.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/Http2Multiplexer.scala
@@ -17,7 +17,6 @@ import org.apache.pekko
import pekko.annotation.InternalApi
import pekko.event.LoggingAdapter
import pekko.http.impl.engine.http2.FrameEvent._
-import pekko.http.ccompat._
import pekko.http.scaladsl.settings.Http2CommonSettings
import pekko.macros.LogHelper
import pekko.stream.stage.GraphStageLogic
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/client/ResponseParsing.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/client/ResponseParsing.scala
index 0f25c2d3d..c5eadecdc 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/client/ResponseParsing.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/client/ResponseParsing.scala
@@ -89,7 +89,7 @@ private[http2] object ResponseParsing {
case ("content-type", ct: String) =>
if (contentType.isEmpty) {
val contentTypeValue =
- ContentType.parse(ct).right.getOrElse(malformedRequest(s"Invalid
content-type: '$ct'"))
+ ContentType.parse(ct).getOrElse(malformedRequest(s"Invalid
content-type: '$ct'"))
rec(remainingHeaders.tail, status,
OptionVal.Some(contentTypeValue), contentLength, seenRegularHeader,
headers)
} else malformedRequest("HTTP message must not contain more than one
content-type header")
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/Http2HeaderParsing.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/Http2HeaderParsing.scala
index dbe68f063..ae135cceb 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/Http2HeaderParsing.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/http2/hpack/Http2HeaderParsing.scala
@@ -60,7 +60,7 @@ private[pekko] object Http2HeaderParsing {
}
object ContentType extends HeaderParser[model.ContentType]("content-type") {
override def parse(name: String, value: String, parserSettings:
ParserSettings): model.ContentType =
-
model.ContentType.parse(value).right.getOrElse(malformedRequest(s"Invalid
content-type: '$value'"))
+ model.ContentType.parse(value).getOrElse(malformedRequest(s"Invalid
content-type: '$value'"))
}
object ContentLength extends Verbatim("content-length")
object Cookie extends Verbatim("cookie")
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala
index c7bdbda34..efcefe5e5 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/engine/parsing/HttpHeaderParser.scala
@@ -26,7 +26,6 @@ import pekko.http.scaladsl.settings.ParserSettings.{
IllegalResponseHeaderNameProcessingMode,
IllegalResponseHeaderValueProcessingMode
}
-import pekko.http.ccompat._
import pekko.http.impl.util._
import pekko.http.impl.util.HttpConstants._
import pekko.http.scaladsl.model.{ ErrorInfo, HttpHeader, MediaTypes,
StatusCode, StatusCodes }
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedByteStringTraversableOnce.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedByteStringTraversableOnce.scala
index 56c9bdec7..0b202481f 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedByteStringTraversableOnce.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedByteStringTraversableOnce.scala
@@ -22,5 +22,5 @@ import pekko.util.ByteString
*/
@InternalApi
private[http] class EnhancedByteStringTraversableOnce(val byteStrings:
IterableOnce[ByteString]) extends AnyVal {
- def join: ByteString = byteStrings.foldLeft(ByteString.empty)(_ ++ _)
+ def join: ByteString = byteStrings.iterator.foldLeft(ByteString.empty)(_ ++
_)
}
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedString.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedString.scala
index 467d7973f..7640789c8 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedString.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/impl/util/EnhancedString.scala
@@ -54,13 +54,13 @@ private[http] class EnhancedString(val underlying: String)
extends AnyVal {
* leading and trailing delimiters are NOT ignored, i.e. they trigger the
inclusion of an
* empty leading or trailing empty string (respectively).
*/
- def lazySplit(delimiter: Char): Stream[String] = {
- def split(start: Int = 0): Stream[String] = {
+ def lazySplit(delimiter: Char): LazyList[String] = {
+ def split(start: Int = 0): LazyList[String] = {
val ix = underlying.indexOf(delimiter, start)
if (ix < 0)
- Stream.cons(underlying.substring(start), Stream.Empty)
+ LazyList.cons(underlying.substring(start), LazyList.empty[String])
else
- Stream.cons(underlying.substring(start, ix), split(ix + 1))
+ LazyList.cons(underlying.substring(start, ix), split(ix + 1))
}
split()
}
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/impl/util/package.scala
b/http-core/src/main/scala/org/apache/pekko/http/impl/util/package.scala
index 3c2273d8a..aed71ff3b 100644
--- a/http-core/src/main/scala/org/apache/pekko/http/impl/util/package.scala
+++ b/http-core/src/main/scala/org/apache/pekko/http/impl/util/package.scala
@@ -50,7 +50,7 @@ package object util {
private[http] implicit def enhanceString_(s: String): EnhancedString = new
EnhancedString(s)
private[http] implicit def enhanceRegex(regex: Regex): EnhancedRegex = new
EnhancedRegex(regex)
private[http] implicit def enhanceByteStrings(
- byteStrings: TraversableOnce[ByteString]):
EnhancedByteStringTraversableOnce =
+ byteStrings: IterableOnce[ByteString]):
EnhancedByteStringTraversableOnce =
new EnhancedByteStringTraversableOnce(byteStrings)
private[http] implicit def enhanceByteStringsMat[Mat](
byteStrings: Source[ByteString, Mat]): EnhancedByteStringSource[Mat] =
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ClientConnectionSettings.scala
b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ClientConnectionSettings.scala
index 3060fe603..7a7a0157d 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ClientConnectionSettings.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ClientConnectionSettings.scala
@@ -55,8 +55,8 @@ abstract class ClientConnectionSettings private[pekko] () {
self: ClientConnecti
*/
final def getIdleTimeout: JDuration =
JavaDurationConverter.toJava(idleTimeout)
final def getSocketOptions: java.lang.Iterable[SocketOption] =
socketOptions.asJava
- final def getUserAgentHeader: Optional[UserAgent] = (userAgentHeader:
Option[UserAgent]).asJava
- final def getLogUnencryptedNetworkBytes: Optional[Int] =
(logUnencryptedNetworkBytes: Option[Int]).asJava
+ final def getUserAgentHeader: Optional[UserAgent] = (userAgentHeader:
Option[UserAgent]).toJava
+ final def getLogUnencryptedNetworkBytes: Optional[Int] =
logUnencryptedNetworkBytes.toJava
/**
* In 2.0.0, the return type of this method changed from
`scala.concurrent.duration.Duration`
@@ -68,7 +68,7 @@ abstract class ClientConnectionSettings private[pekko] () {
self: ClientConnecti
final def getWebsocketRandomFactory: Supplier[Random] = new Supplier[Random]
{
override def get(): Random = websocketRandomFactory()
}
- final def getLocalAddress: Optional[InetSocketAddress] = (localAddress:
Option[InetSocketAddress]).asJava
+ final def getLocalAddress: Optional[InetSocketAddress] = localAddress.toJava
/** The underlying transport used to connect to hosts. By default
[[ClientTransport.TCP]] is used. */
@ApiMayChange
@@ -102,9 +102,9 @@ abstract class ClientConnectionSettings private[pekko] () {
self: ClientConnecti
def withStreamCancellationDelay(newValue: java.time.Duration):
ClientConnectionSettings
def withUserAgentHeader(newValue: Optional[UserAgent]):
ClientConnectionSettings =
- self.copy(userAgentHeader = (newValue.asScala:
Option[UserAgent]).map(_.asScala))
+ self.copy(userAgentHeader = newValue.toScala.map(_.asScala))
def withLogUnencryptedNetworkBytes(newValue: Optional[Int]):
ClientConnectionSettings =
- self.copy(logUnencryptedNetworkBytes = newValue.asScala)
+ self.copy(logUnencryptedNetworkBytes = newValue.toScala)
def withWebsocketRandomFactory(newValue:
java.util.function.Supplier[Random]): ClientConnectionSettings =
self.copy(websocketSettings =
websocketSettings.withRandomFactoryFactory(new Supplier[Random] {
override def get(): Random = newValue.get()
@@ -116,7 +116,7 @@ abstract class ClientConnectionSettings private[pekko] () {
self: ClientConnecti
def withParserSettings(newValue: ParserSettings): ClientConnectionSettings =
self.copy(parserSettings = newValue.asScala)
def withLocalAddress(newValue: Optional[InetSocketAddress]):
ClientConnectionSettings =
- self.copy(localAddress = newValue.asScala)
+ self.copy(localAddress = newValue.toScala)
@ApiMayChange
def withTransport(newValue: ClientTransport): ClientConnectionSettings =
self.copy(transport = newValue.asScala)
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala
b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala
index 8044e7080..15ca39707 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/javadsl/settings/ServerSettings.scala
@@ -59,7 +59,7 @@ import scala.concurrent.duration.{ Duration, FiniteDuration }
// ---
def withServerHeader(newValue: Optional[Server]): ServerSettings =
- self.copy(serverHeader = newValue.asScala.map(_.asScala))
+ self.copy(serverHeader = newValue.toScala.map(_.asScala))
def withPreviewServerSettings(newValue: PreviewServerSettings):
ServerSettings =
self.copy(previewServerSettings = newValue.asScala)
def withTimeouts(newValue: ServerSettings.Timeouts): ServerSettings =
self.copy(timeouts = newValue.asScala)
diff --git a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala
index 89e35bf5f..17a5044a1 100644
--- a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala
+++ b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/Http.scala
@@ -90,8 +90,6 @@ class HttpExt @InternalStableApi /* constructor signature is
hardcoded in Teleme
// ** SERVER ** //
- private[this] final val DefaultPortForProtocol = -1 // any negative value
-
// Date header rendering is shared across the system, so that date is only
rendered once a second
private[http] val dateHeaderRendering = DateHeaderRendering()
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ContentType.scala
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ContentType.scala
index 1f7c15e26..b90b17f4b 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ContentType.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/ContentType.scala
@@ -129,7 +129,7 @@ object ContentType {
* `Left(errors)` otherwise.
*/
def parse(value: String): Either[List[ErrorInfo], ContentType] =
- headers.`Content-Type`.parseFromValueString(value).right.map(_.contentType)
+ headers.`Content-Type`.parseFromValueString(value).map(_.contentType)
private[http] case object `; charset=` extends SingletonValueRenderable
}
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/MediaType.scala
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/MediaType.scala
index 26c06b231..41e43be36 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/MediaType.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/MediaType.scala
@@ -207,7 +207,7 @@ object MediaType {
* Returns `Right(mediaType)` if successful and `Left(errors)` otherwise.
*/
def parse(value: String): Either[List[ErrorInfo], MediaType] =
- ContentType.parse(value).right.map(_.mediaType)
+ ContentType.parse(value).map(_.mediaType)
def unapply(mediaType: MediaType): Option[String] = Some(mediaType.value)
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpChallenge.scala
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpChallenge.scala
index 558948690..e14861f70 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpChallenge.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpChallenge.scala
@@ -29,7 +29,7 @@ final case class HttpChallenge(scheme: String, realm: String,
def render[R <: Rendering](r: R): r.type = {
r ~~ scheme
- val paramsNoToken = params.filterKeys(_ != "")
+ val paramsNoToken = params.view.filterKeys(_ != "")
if (params.contains("")) r ~~ " " ~~ params("")
if (realm != null) r ~~ " realm=" ~~#! realm
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpCookie.scala
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpCookie.scala
index 903292ce3..a6dd33aed 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpCookie.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/HttpCookie.scala
@@ -158,13 +158,13 @@ final class HttpCookie private[http] (
def getSameSite: Optional[jm.headers.SameSite] =
sameSite.map(_.asJava).toJava
/** Java API */
- def getExtension: Optional[String] = extension.asJava
+ def getExtension: Optional[String] = extension.toJava
/** Java API */
- def getPath: Optional[String] = path.asJava
+ def getPath: Optional[String] = path.toJava
/** Java API */
- def getDomain: Optional[String] = domain.asJava
+ def getDomain: Optional[String] = domain.toJava
/** Java API */
def getMaxAge: OptionalLong = maxAge.toJavaPrimitive
diff --git
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LanguageRange.scala
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LanguageRange.scala
index b5433d5ef..3bc0a8d02 100644
---
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LanguageRange.scala
+++
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/headers/LanguageRange.scala
@@ -15,6 +15,7 @@ package org.apache.pekko.http.scaladsl.model.headers
import scala.language.implicitConversions
import scala.collection.immutable
+
import org.apache.pekko
import pekko.http.impl.util._
import pekko.http.scaladsl.model.WithQValue
@@ -79,7 +80,7 @@ object Language {
implicit def apply(compoundTag: String): Language =
if (compoundTag.indexOf('-') >= 0) {
val tags = compoundTag.split('-')
- new Language(tags.head, immutable.Seq(tags.tail: _*))
+ new Language(tags.head, immutable.ArraySeq.unsafeWrapArray(tags.tail))
} else new Language(compoundTag, immutable.Seq.empty)
def apply(primaryTag: String, firstSubTag: String, otherSubTags: String*):
Language =
new Language(primaryTag, firstSubTag +: otherSubTags)
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/HashCodeCollider.scala
b/http-core/src/test/scala/org/apache/pekko/http/HashCodeCollider.scala
index f47e32b2d..bfd18677a 100644
--- a/http-core/src/test/scala/org/apache/pekko/http/HashCodeCollider.scala
+++ b/http-core/src/test/scala/org/apache/pekko/http/HashCodeCollider.scala
@@ -21,9 +21,9 @@ package org.apache.pekko.http
*/
object HashCodeCollider {
val visibleChars = (33 until 127).filterNot(c => c == '\\' || c == '"')
- def asciiChars: Iterator[Int] = visibleChars.toIterator
+ def asciiChars: Iterator[Int] = visibleChars.iterator
def asciiCharsAndHash(previousHash: Int): Iterator[(Int, Int)] =
- visibleChars.toIterator.map(c => c -> (previousHash + c) * 31)
+ visibleChars.iterator.map(c => c -> (previousHash + c) * 31)
/** Creates an iterator of Strings that all have hashCode == 0 */
def zeroHashCodeIterator(): Iterator[String] =
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/BoyerMooreSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/BoyerMooreSpec.scala
index 824c3c1f2..b84651f10 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/BoyerMooreSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/BoyerMooreSpec.scala
@@ -38,7 +38,7 @@ class BoyerMooreSpec extends AnyWordSpec with Matchers {
val haystackLen = 1000
(0 to 9).foreach { run =>
val alphabet = alphabetBase.take(4 + random.nextInt(5)) // 4 to 8
distinct alphanumeric chars
- val randomAlphabetChars =
Stream.continually(alphabet(random.nextInt(alphabet.length)))
+ val randomAlphabetChars =
LazyList.continually(alphabet(random.nextInt(alphabet.length)))
def randomBytes(num: Int): ByteString =
ByteString(randomAlphabetChars.take(num): _*)
val haystack = randomBytes(haystackLen)
val needle = randomBytes(run / 3 + 3) // 3 to 6 random alphabet chars
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/ResponseParserSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/ResponseParserSpec.scala
index c196d70b2..9cfee9e1e 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/ResponseParserSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/ResponseParserSpec.scala
@@ -385,7 +385,7 @@ abstract class ResponseParserSpec(mode: String, newLine:
String) extends PekkoSp
}
def strictEqualify[T](x: Either[T, HttpResponse]): Either[T,
StrictEqualHttpResponse] =
- x.right.map(new StrictEqualHttpResponse(_))
+ x.map(new StrictEqualHttpResponse(_))
def parseTo(expected: HttpResponse*): Matcher[String] = parseTo(GET,
expected: _*)
def parseTo(requestMethod: HttpMethod, expected: HttpResponse*):
Matcher[String] =
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala
index 281c22842..644d0f075 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/impl/model/parser/HttpHeaderSpec.scala
@@ -30,7 +30,6 @@ import pekko.http.scaladsl.model.HttpCharsets._
import pekko.http.scaladsl.model.HttpMethods._
import pekko.http.scaladsl.model.headers.{ Trailer => `Trailer`, _ }
import pekko.http.scaladsl.model.headers.CacheDirectives._
-import pekko.http.scaladsl.model.headers.CacheDirectives._
import pekko.http.scaladsl.model.headers.HttpEncodings._
import org.scalatest.exceptions.TestFailedException
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/impl/util/WithLogCapturing.scala
b/http-core/src/test/scala/org/apache/pekko/http/impl/util/WithLogCapturing.scala
index c12e4bc73..4be422b6e 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/impl/util/WithLogCapturing.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/impl/util/WithLogCapturing.scala
@@ -86,7 +86,7 @@ trait WithLogCapturing extends SuiteMixin { this: TestSuite =>
flushLog()
res
} else if (failOnSevereMessages && events.exists(isSevere)) {
- val stats =
events.groupBy(_.level).mapValues(_.size).toMap.withDefaultValue(0)
+ val stats =
events.groupBy(_.level).view.mapValues(_.size).toMap.withDefaultValue(0)
flushLog()
Failed(new AssertionError(
@@ -96,7 +96,7 @@ trait WithLogCapturing extends SuiteMixin { this: TestSuite =>
val severeEvents = events.filter(isSevere(_))
val matchingEvents =
severeEvents.filter(_.message.toString.contains(expectSevereLogsOnlyToMatch.get))
if (severeEvents.isEmpty || matchingEvents != severeEvents) {
- val stats =
events.groupBy(_.level).mapValues(_.size).toMap.withDefaultValue(0)
+ val stats =
events.groupBy(_.level).view.mapValues(_.size).toMap.withDefaultValue(0)
flushLog()
Failed(new AssertionError(
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/model/DateTimeSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/model/DateTimeSpec.scala
index b053a39de..75bf73bc4 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/model/DateTimeSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/model/DateTimeSpec.scala
@@ -26,7 +26,7 @@ class DateTimeSpec extends AnyWordSpec with Matchers {
val startClicks = DateTime(1800, 1, 1, 0, 0, 0).clicks
val maxClickDelta = DateTime(2199, 12, 31, 23, 59, 59).clicks - startClicks
val random = new Random()
- val httpDateTimes = Stream.continually {
+ val httpDateTimes = LazyList.continually {
DateTime(startClicks + math.abs(random.nextLong()) % maxClickDelta)
}
diff --git
a/http-tests/src/test/scala/org/apache/pekko/http/HashCodeCollider.scala
b/http-tests/src/test/scala/org/apache/pekko/http/HashCodeCollider.scala
index f47e32b2d..bfd18677a 100644
--- a/http-tests/src/test/scala/org/apache/pekko/http/HashCodeCollider.scala
+++ b/http-tests/src/test/scala/org/apache/pekko/http/HashCodeCollider.scala
@@ -21,9 +21,9 @@ package org.apache.pekko.http
*/
object HashCodeCollider {
val visibleChars = (33 until 127).filterNot(c => c == '\\' || c == '"')
- def asciiChars: Iterator[Int] = visibleChars.toIterator
+ def asciiChars: Iterator[Int] = visibleChars.iterator
def asciiCharsAndHash(previousHash: Int): Iterator[(Int, Int)] =
- visibleChars.toIterator.map(c => c -> (previousHash + c) * 31)
+ visibleChars.iterator.map(c => c -> (previousHash + c) * 31)
/** Creates an iterator of Strings that all have hashCode == 0 */
def zeroHashCodeIterator(): Iterator[String] =
diff --git
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CoderSpec.scala
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CoderSpec.scala
index 89fb17d95..672adf0ef 100644
---
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CoderSpec.scala
+++
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/coding/CoderSpec.scala
@@ -159,7 +159,7 @@ abstract class CoderSpec extends AnyWordSpec with
CodecSpecSupport with Inspecto
ByteString(Array.fill(size)(1.toByte))
val sizesAfterRoundtrip =
- Source.fromIterator(() => sizes.toIterator.map(createByteString))
+ Source.fromIterator(() => sizes.iterator.map(createByteString))
.via(Coder.encoderFlow)
.via(Coder.decoderFlow)
.runFold(Seq.empty[Int])(_ :+ _.size)
diff --git
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultExceptionHandlerSpec.scala
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultExceptionHandlerSpec.scala
index 7c7009f11..5e4469979 100644
---
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultExceptionHandlerSpec.scala
+++
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultExceptionHandlerSpec.scala
@@ -43,7 +43,7 @@ class DiscardEntityDefaultExceptionHandlerSpec extends
RoutingSpec with ScalaFut
trait Fixture {
@volatile
var streamConsumed = false
- val thousandElements: Stream[ByteString] =
Stream.continually(ByteString("foo")).take(999).lazyAppendedAll {
+ val thousandElements: LazyList[ByteString] =
LazyList.continually(ByteString("foo")).take(999).lazyAppendedAll {
streamConsumed = true
Seq(ByteString("end"))
}
diff --git
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultRejectionHandlerSpec.scala
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultRejectionHandlerSpec.scala
index 78cc0ee6a..84d75c238 100644
---
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultRejectionHandlerSpec.scala
+++
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/DiscardEntityDefaultRejectionHandlerSpec.scala
@@ -37,7 +37,7 @@ class DiscardEntityDefaultRejectionHandlerSpec extends
RoutingSpec with ScalaFut
ByteString("Foo")
}
- private val ThousandElements: Stream[ByteString] =
Stream.continually(gimmeElement()).take(numElems)
+ private val ThousandElements: LazyList[ByteString] =
LazyList.continually(gimmeElement()).take(numElems)
private val RequestToNotHandled = Get("/bar",
HttpEntity(`text/plain(UTF-8)`, Source[ByteString](ThousandElements)))
"Default RejectionHandler" should {
diff --git
a/http/src/main/scala/org/apache/pekko/http/javadsl/server/Rejections.scala
b/http/src/main/scala/org/apache/pekko/http/javadsl/server/Rejections.scala
index ea4dc0593..63d50c2dc 100644
--- a/http/src/main/scala/org/apache/pekko/http/javadsl/server/Rejections.scala
+++ b/http/src/main/scala/org/apache/pekko/http/javadsl/server/Rejections.scala
@@ -405,7 +405,7 @@ object Rejections {
contentType: Optional[ContentType]):
UnsupportedRequestContentTypeRejection =
s.UnsupportedRequestContentTypeRejection(
supported = supported.asScala.map((m: MediaType) =>
scaladsl.model.ContentTypeRange(m.asScala)).toSet,
- contentType = contentType.asScala.map((c: ContentType) => c.asScala))
+ contentType = contentType.toScala.map((c: ContentType) => c.asScala))
// for backwards compatibility
def unsupportedRequestContentType(supported: java.lang.Iterable[MediaType]):
UnsupportedRequestContentTypeRejection =
diff --git
a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/FormFieldDirectives.scala
b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/FormFieldDirectives.scala
index fdf660d38..2845142cd 100644
---
a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/FormFieldDirectives.scala
+++
b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/FormFieldDirectives.scala
@@ -37,7 +37,7 @@ abstract class FormFieldDirectives extends
FileUploadDirectives {
@CorrespondsTo("formField")
def formFieldOptional(name: String, inner: JFunction[Optional[String],
Route]): Route = RouteAdapter(
D.formField(name.optional) { value =>
- inner.apply(value.asJava).delegate
+ inner.apply(value.toJava).delegate
})
@CorrespondsTo("formFieldSeq")
@@ -83,7 +83,7 @@ abstract class FormFieldDirectives extends
FileUploadDirectives {
* Extracts HTTP form fields from the request as a ``Map<String,
List<String>>``.
*/
def formFieldMultiMap(inner: JFunction[JMap[String, JList[String]], Route]):
Route = RouteAdapter {
- D.formFieldMultiMap { map => inner.apply(map.mapValues { l => l.asJava
}.toMap.asJava).delegate }
+ D.formFieldMultiMap { map => inner.apply(map.view.mapValues { l =>
l.asJava }.toMap.asJava).delegate }
}
/**
diff --git
a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/ParameterDirectives.scala
b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/ParameterDirectives.scala
index b6c8dd6f8..76979da90 100644
---
a/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/ParameterDirectives.scala
+++
b/http/src/main/scala/org/apache/pekko/http/javadsl/server/directives/ParameterDirectives.scala
@@ -98,7 +98,7 @@ abstract class ParameterDirectives extends MiscDirectives {
}
def parameterMultiMap(inner: JFunction[JMap[String, JList[String]], Route]):
Route = RouteAdapter {
- D.parameterMultiMap { map => inner.apply(map.mapValues { l => l.asJava
}.toMap.asJava).delegate }
+ D.parameterMultiMap { map => inner.apply(map.view.mapValues { l =>
l.asJava }.toMap.asJava).delegate }
}
@CorrespondsTo("parameterSeq")
diff --git
a/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/Unmarshaller.scala
b/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/Unmarshaller.scala
index f99f247f3..8fe9cbb5b 100644
---
a/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/Unmarshaller.scala
+++
b/http/src/main/scala/org/apache/pekko/http/scaladsl/unmarshalling/Unmarshaller.scala
@@ -175,7 +175,7 @@ object Unmarshaller
val supported: Set[ContentTypeRange] =
_supported.asScala.toSet.asInstanceOf[Set[pekko.http.scaladsl.model.ContentTypeRange]]
- val actualContentType: Option[ContentType] =
_actualContentType.asScala.map(_.asScala)
+ val actualContentType: Option[ContentType] =
_actualContentType.toScala.map(_.asScala)
def this(supported: Set[ContentTypeRange], actualContentType:
Option[ContentType]) =
this(supported.asJava.asInstanceOf[java.util.Set[jm.model.ContentTypeRange]],
diff --git a/project/Common.scala b/project/Common.scala
index 0b76bf1e0..ce7270438 100644
--- a/project/Common.scala
+++ b/project/Common.scala
@@ -25,18 +25,11 @@ object Common extends AutoPlugin {
"-encoding", "UTF-8", // yes, this is 2 args
"-unchecked",
"-Ywarn-dead-code",
- // Silence deprecation notices for changes introduced in Scala 2.12
- // Can be removed when we drop support for Scala 2.12:
- "-Wconf:msg=object JavaConverters in package collection is deprecated:s",
- "-Wconf:msg=is deprecated \\(since 2\\.13\\.:s",
"-Wconf:msg=reached max recursion depth:s",
"-Wconf:msg=Prefer the Scala annotation over Java's `@Deprecated`:s",
"-release:" + javacTarget),
scalacOptions ++= onlyOnScala2(Seq(
"-Xlint",
- // Silence deprecation notices for changes introduced in Scala 2.12
- // Can be removed when we drop support for Scala 2.12:
- "-Wconf:cat=unused-imports&origin=org.apache.pekko.http.ccompat.*:s",
// Exhaustivity checking is only useful for simple sealed hierarchies
and matches without filters.
// In all other cases, the warning is non-actionable: you get spurious
warnings that need to be suppressed
// verbosely. So, opt out of those in general.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]