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 717f29e65 try to remove unnecessary map calls (#811)
717f29e65 is described below

commit 717f29e65b059ca7363da18c3a59637e61ec2754
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Oct 2 23:51:01 2025 +0100

    try to remove unnecessary map calls (#811)
    
    Update SizeLimitSpec.scala
---
 .../src/main/scala/org/apache/pekko/http/javadsl/ServerBinding.scala  | 4 ++--
 .../main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala | 2 +-
 .../scala/org/apache/pekko/http/scaladsl/server/RejectionSpec.scala   | 2 +-
 .../scaladsl/unmarshalling/sse/EventStreamUnmarshallingSpec.scala     | 2 +-
 .../pekko/http/javadsl/marshalling/sse/EventStreamMarshalling.scala   | 2 +-
 .../http/javadsl/unmarshalling/sse/EventStreamUnmarshalling.scala     | 2 +-
 6 files changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/http-core/src/main/scala/org/apache/pekko/http/javadsl/ServerBinding.scala 
b/http-core/src/main/scala/org/apache/pekko/http/javadsl/ServerBinding.scala
index 41bc56fe3..1657f77a7 100644
--- a/http-core/src/main/scala/org/apache/pekko/http/javadsl/ServerBinding.scala
+++ b/http-core/src/main/scala/org/apache/pekko/http/javadsl/ServerBinding.scala
@@ -89,8 +89,8 @@ class ServerBinding private[http] (delegate: 
pekko.http.scaladsl.Http.ServerBind
 
   def terminate(hardDeadline: java.time.Duration): 
CompletionStage[HttpTerminated] = {
     delegate.terminate(FiniteDuration.apply(hardDeadline.toMillis, 
TimeUnit.MILLISECONDS))
-      .map(_.asInstanceOf[HttpTerminated])(ExecutionContext.parasitic)
       .asJava
+      .asInstanceOf[CompletionStage[HttpTerminated]]
   }
 
   /**
@@ -120,8 +120,8 @@ class ServerBinding private[http] (delegate: 
pekko.http.scaladsl.Http.ServerBind
    */
   def whenTerminated: CompletionStage[HttpTerminated] =
     delegate.whenTerminated
-      .map(_.asInstanceOf[HttpTerminated])(ExecutionContext.parasitic)
       .asJava
+      .asInstanceOf[CompletionStage[HttpTerminated]]
 
   /**
    * Adds this `ServerBinding` to the actor system's coordinated shutdown, so 
that [[unbind]] and [[terminate]] get
diff --git 
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala
 
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala
index d3c6c2599..eb1034419 100644
--- 
a/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala
+++ 
b/http-core/src/main/scala/org/apache/pekko/http/scaladsl/model/HttpMessage.scala
@@ -152,7 +152,7 @@ sealed trait HttpMessage extends jm.HttpMessage {
   }
 
   def attribute[T](key: jm.AttributeKey[T])(implicit ev: 
JavaMapping[jm.AttributeKey[T], AttributeKey[T]]): Option[T] =
-    attributes.get(ev.toScala(key)).map(_.asInstanceOf[T])
+    attributes.get(ev.toScala(key)).asInstanceOf[Option[T]]
 
   /**
    * Returns true if this message is an:
diff --git 
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/RejectionSpec.scala
 
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/RejectionSpec.scala
index 6ba88bb5d..ce24a8c7f 100644
--- 
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/RejectionSpec.scala
+++ 
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/server/RejectionSpec.scala
@@ -25,7 +25,7 @@ class RejectionSpec extends RoutingSpec {
       import pekko.http.javadsl.{ server => jserver }
       val rejections = List(RequestEntityExpectedRejection)
       val jrejections: java.lang.Iterable[jserver.Rejection] =
-        rejections.map(_.asInstanceOf[jserver.Rejection]).asJava
+        rejections.asJava.asInstanceOf[java.lang.Iterable[jserver.Rejection]]
       val jresult = 
TransformationRejection(identity).getTransform.apply(jrejections)
 
       val result = jresult.asScala.map(r => r.asInstanceOf[Rejection])
diff --git 
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/EventStreamUnmarshallingSpec.scala
 
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/EventStreamUnmarshallingSpec.scala
index 46d884a02..a8cf7d5a3 100644
--- 
a/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/EventStreamUnmarshallingSpec.scala
+++ 
b/http-tests/src/test/scala/org/apache/pekko/http/scaladsl/unmarshalling/sse/EventStreamUnmarshallingSpec.scala
@@ -39,7 +39,7 @@ object EventStreamUnmarshallingSpec {
   // Also used by EventStreamUnmarshallingTest.java
   val eventsAsJava: JList[javadsl.model.sse.ServerSentEvent] = {
     import scala.jdk.CollectionConverters._
-    events.map(_.asInstanceOf[javadsl.model.sse.ServerSentEvent]).asJava
+    events.asJava.asInstanceOf[JList[javadsl.model.sse.ServerSentEvent]]
   }
 
   // Also used by EventStreamUnmarshallingTest.java
diff --git 
a/http/src/main/scala/org/apache/pekko/http/javadsl/marshalling/sse/EventStreamMarshalling.scala
 
b/http/src/main/scala/org/apache/pekko/http/javadsl/marshalling/sse/EventStreamMarshalling.scala
index 8a0925fd5..47ca5c18d 100644
--- 
a/http/src/main/scala/org/apache/pekko/http/javadsl/marshalling/sse/EventStreamMarshalling.scala
+++ 
b/http/src/main/scala/org/apache/pekko/http/javadsl/marshalling/sse/EventStreamMarshalling.scala
@@ -32,7 +32,7 @@ object EventStreamMarshalling {
    */
   val toEventStream: Marshaller[Source[ServerSentEvent, NotUsed], 
RequestEntity] = {
     def asScala(eventStream: Source[ServerSentEvent, NotUsed]) =
-      
eventStream.asScala.map(_.asInstanceOf[scaladsl.model.sse.ServerSentEvent])
+      
eventStream.asScala.asInstanceOf[pekko.stream.scaladsl.Source[scaladsl.model.sse.ServerSentEvent,
 NotUsed]]
     
Marshaller.fromScala(scaladsl.marshalling.sse.EventStreamMarshalling.toEventStream.compose(asScala))
   }
 }
diff --git 
a/http/src/main/scala/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshalling.scala
 
b/http/src/main/scala/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshalling.scala
index a487e49aa..d1ea000de 100644
--- 
a/http/src/main/scala/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshalling.scala
+++ 
b/http/src/main/scala/org/apache/pekko/http/javadsl/unmarshalling/sse/EventStreamUnmarshalling.scala
@@ -50,7 +50,7 @@ object EventStreamUnmarshalling {
   private def asHttpEntityUnmarshaller(value: 
FromEntityUnmarshaller[scaladsl.Source[sse.ServerSentEvent, NotUsed]])
       : Unmarshaller[HttpEntity, Source[ServerSentEvent, NotUsed]] = {
     value
-      .map(_.map(_.asInstanceOf[ServerSentEvent]).asJava)
+      .map(_.asJava)
       .asInstanceOf[Unmarshaller[HttpEntity, Source[ServerSentEvent, NotUsed]]]
   }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to