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 407114784 fix some compiler warnings related to use of Either (#815)
407114784 is described below
commit 407114784f1d68c278d54027886733de7737a385
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Oct 2 18:41:20 2025 +0100
fix some compiler warnings related to use of Either (#815)
* fix some compiler warnings related to use of Either
* Update Http2FrameHpackSupport.scala
---
.../pekko/http/impl/engine/parsing/RequestParserSpec.scala | 4 ++--
.../http/scaladsl/settings/ConnectionPoolSettingsSpec.scala | 4 ++--
.../apache/pekko/http/scaladsl/CustomMediaTypesSpec.scala | 12 ++++++------
.../pekko/http/scaladsl/server/EntityStreamingSpec.scala | 2 +-
.../server/directives/MarshallingDirectivesSpec.scala | 4 ++--
.../pekko/http/impl/engine/http2/HPackSpecExamples.scala | 6 +++---
.../http/impl/engine/http2/Http2FrameHpackSupport.scala | 5 +++--
7 files changed, 19 insertions(+), 18 deletions(-)
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/RequestParserSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/RequestParserSpec.scala
index 82db1d8c4..f640b13af 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/RequestParserSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/impl/engine/parsing/RequestParserSpec.scala
@@ -341,7 +341,7 @@ abstract class RequestParserSpec(mode: String, newLine:
String) extends AnyFreeS
val manyChunks = (oneChunk * numChunks) + s"0${newLine}"
val result = multiParse(newParser)(Seq(prep(start + manyChunks)))
- val HttpEntity.Chunked(_, chunks) = result.head.right.get.req.entity
+ val HttpEntity.Chunked(_, chunks) = result.head.toOption.get.req.entity
val strictChunks =
chunks.limit(100000).runWith(Sink.seq).awaitResult(awaitAtMost)
strictChunks.size shouldEqual numChunks
}
@@ -766,7 +766,7 @@ abstract class RequestParserSpec(mode: String, newLine:
String) extends AnyFreeS
}
def strictEqualify[T](x: Either[T, HttpRequest]): Either[T,
StrictEqualHttpRequest] =
- x.right.map(new StrictEqualHttpRequest(_))
+ x.map(new StrictEqualHttpRequest(_))
def parseTo(expected: HttpRequest*): Matcher[String] =
multiParseTo(expected: _*).compose(_ :: Nil)
diff --git
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ConnectionPoolSettingsSpec.scala
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ConnectionPoolSettingsSpec.scala
index fe2a3fe98..5ae2fa707 100644
---
a/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ConnectionPoolSettingsSpec.scala
+++
b/http-core/src/test/scala/org/apache/pekko/http/scaladsl/settings/ConnectionPoolSettingsSpec.scala
@@ -30,7 +30,7 @@ class ConnectionPoolSettingsSpec extends PekkoSpec {
""")
settings.connectionSettings.userAgentHeader shouldEqual Some(
- `User-Agent`.parseFromValueString("serva/0.0").right.get)
+ `User-Agent`.parseFromValueString("serva/0.0").toOption.get)
}
"allow overriding client settings with
pekko.http.host-connection-pool.client" in {
val settings = config(
@@ -41,7 +41,7 @@ class ConnectionPoolSettingsSpec extends PekkoSpec {
""")
settings.connectionSettings.userAgentHeader shouldEqual Some(
- `User-Agent`.parseFromValueString("serva/5.7").right.get)
+ `User-Agent`.parseFromValueString("serva/5.7").toOption.get)
settings.connectionSettings.requestHeaderSizeHint shouldEqual 1024 //
still fall back
}
"allow max-open-requests = 1" in {
diff --git
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/CustomMediaTypesSpec.scala
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/CustomMediaTypesSpec.scala
index 4ba029241..e06219058 100644
---
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/CustomMediaTypesSpec.scala
+++
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/CustomMediaTypesSpec.scala
@@ -36,12 +36,12 @@ class CustomMediaTypesSpec extends PekkoSpec with
ScalaFutures
set.add(MediaTypes.`application/msword`)
set.add(MediaType.customBinary("application", "x-Pekko-TEST",
MediaType.NotCompressible))
- set.contains(MediaType.parse("application/msword").right.get) should
===(true)
- set.contains(MediaType.parse("application/MsWord").right.get) should
===(true)
- set.contains(MediaType.parse("application/vnd.ms-POWERPOINT").right.get)
should ===(true)
- set.contains(MediaType.parse("application/VnD.MS-eXceL").right.get)
should ===(true)
- set.contains(MediaType.parse("application/x-pekko-test").right.get)
should ===(true)
- set.contains(MediaType.parse("application/x-Pekko-TEST").right.get)
should ===(true)
+ set.contains(MediaType.parse("application/msword").toOption.get) should
===(true)
+ set.contains(MediaType.parse("application/MsWord").toOption.get) should
===(true)
+
set.contains(MediaType.parse("application/vnd.ms-POWERPOINT").toOption.get)
should ===(true)
+ set.contains(MediaType.parse("application/VnD.MS-eXceL").toOption.get)
should ===(true)
+ set.contains(MediaType.parse("application/x-pekko-test").toOption.get)
should ===(true)
+ set.contains(MediaType.parse("application/x-Pekko-TEST").toOption.get)
should ===(true)
}
"allow registering custom media type" in {
diff --git
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/EntityStreamingSpec.scala
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/EntityStreamingSpec.scala
index 84174730d..2d0df78c0 100755
---
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/EntityStreamingSpec.scala
+++
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/EntityStreamingSpec.scala
@@ -383,7 +383,7 @@ class EntityStreamingSpec extends RoutingSpec with
ScalaFutures {
complete(r)
}
- val `Accept:application/example` =
Accept(MediaRange(MediaType.parse("application/example").right.get))
+ val `Accept:application/example` =
Accept(MediaRange(MediaType.parse("application/example").toOption.get))
Get("/").addHeader(`Accept:application/example`) ~> eventsRoute ~> check {
val res = responseAs[String]
diff --git
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectivesSpec.scala
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectivesSpec.scala
index 880eb6034..f93f9a9f2 100644
---
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectivesSpec.scala
+++
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/directives/MarshallingDirectivesSpec.scala
@@ -256,8 +256,8 @@ class MarshallingDirectivesSpec extends RoutingSpec with
Inside {
rejection shouldEqual
UnacceptedResponseContentTypeRejection(Set(ContentType(`application/json`)))
}
}
- val acceptHeaderUtf =
Accept.parseFromValueString("application/json;charset=utf8").right.get
- val acceptHeaderNonUtf =
Accept.parseFromValueString("application/json;charset=ISO-8859-1").right.get
+ val acceptHeaderUtf =
Accept.parseFromValueString("application/json;charset=utf8").toOption.get
+ val acceptHeaderNonUtf =
Accept.parseFromValueString("application/json;charset=ISO-8859-1").toOption.get
"render JSON response when `Accept` header is present with the `charset`
parameter ignoring it" in {
Get().withHeaders(acceptHeaderUtf) ~> complete(foo) ~> check {
responseEntity shouldEqual HttpEntity(`application/json`,
foo.toJson.compactPrint)
diff --git
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HPackSpecExamples.scala
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HPackSpecExamples.scala
index 3e8c68a30..8369468c8 100644
---
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HPackSpecExamples.scala
+++
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/HPackSpecExamples.scala
@@ -174,7 +174,7 @@ object HPackSpecExamples {
302,
headers = Vector(
headers.`Cache-Control`(CacheDirectives.`private`()),
- headers.Date.parseFromValueString("Mon, 21 Oct 2013 20:13:21
GMT").right.get,
+ headers.Date.parseFromValueString("Mon, 21 Oct 2013 20:13:21
GMT").toOption.get,
headers.Location("https://www.example.com")),
entity = HttpEntity.CloseDelimited(ContentTypes.NoContentType,
Source.empty),
protocol = HttpProtocols.`HTTP/2.0`)
@@ -187,7 +187,7 @@ object HPackSpecExamples {
307,
headers = Vector(
headers.`Cache-Control`(CacheDirectives.`private`()),
- headers.Date.parseFromValueString("Mon, 21 Oct 2013 20:13:21
GMT").right.get,
+ headers.Date.parseFromValueString("Mon, 21 Oct 2013 20:13:21
GMT").toOption.get,
headers.Location("https://www.example.com")),
entity = HttpEntity.CloseDelimited(ContentTypes.NoContentType,
Source.empty),
protocol = HttpProtocols.`HTTP/2.0`)
@@ -200,7 +200,7 @@ object HPackSpecExamples {
200,
headers = Vector(
headers.`Cache-Control`(CacheDirectives.`private`()),
- headers.Date.parseFromValueString("Mon, 21 Oct 2013 20:13:22
GMT").right.get,
+ headers.Date.parseFromValueString("Mon, 21 Oct 2013 20:13:22
GMT").toOption.get,
headers.Location("https://www.example.com"),
headers.`Content-Encoding`(HttpEncodings.gzip),
// The RFC example spells 'max-age' in lowercase, while the modeled
`Set-Cookie` header renders it uppercase.
diff --git
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2FrameHpackSupport.scala
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2FrameHpackSupport.scala
index 07cff1158..4099d5649 100644
---
a/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2FrameHpackSupport.scala
+++
b/http2-tests/src/test/scala/org/apache/pekko/http/impl/engine/http2/Http2FrameHpackSupport.scala
@@ -79,7 +79,8 @@ trait Http2FrameHpackSupport extends Http2FrameProbeDelegator
with Http2FrameSen
case ("content-length", value) if value.toLong == 0 =>
old.withEntity(HttpEntity.Empty)
case ("content-length", value) =>
old.withEntity(HttpEntity.Default(old.entity.contentType,
value.toLong, Source.empty))
- case ("content-type", value) =>
old.withEntity(old.entity.withContentType(ContentType.parse(value).right.get))
- case (name, value) => old.addHeader(RawHeader(name, value))
// FIXME: decode to modeled headers
+ case ("content-type", value) =>
+
old.withEntity(old.entity.withContentType(ContentType.parse(value).toOption.get))
+ case (name, value) => old.addHeader(RawHeader(name, value)) // FIXME:
decode to modeled headers
})
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]