This is an automated email from the ASF dual-hosted git repository.
pjfanning pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git
The following commit(s) were added to refs/heads/main by this push:
new 677dd568ba fix(stream): undeprecate getFirst/getFirstAttribute methods
(#3404)
677dd568ba is described below
commit 677dd568baf4c2dda9526c9742f375656f265324
Author: Luis Angel Moreno Delgado <[email protected]>
AuthorDate: Thu Jul 30 18:07:08 2026 -0600
fix(stream): undeprecate getFirst/getFirstAttribute methods (#3404)
* fix(stream): undeprecate getFirst/getFirstAttribute methods
Removes the @deprecated annotation from getFirst and getFirstAttribute as
they are intentionally designed to retrieve the least specific attribute (using
reverseIterator). Replacing them with get() breaks attribute precedence, as
seen in apache/pekko-http#345.
* refactor(stream): mark getFirst as InternalStableApi and update scaladocs
per reviewer feedback
* style: apply scalafmt
* fix: correct typo in InternalStableApi import
---
.../main/scala/org/apache/pekko/stream/Attributes.scala | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/stream/src/main/scala/org/apache/pekko/stream/Attributes.scala
b/stream/src/main/scala/org/apache/pekko/stream/Attributes.scala
index 36583c971c..54f52d5796 100644
--- a/stream/src/main/scala/org/apache/pekko/stream/Attributes.scala
+++ b/stream/src/main/scala/org/apache/pekko/stream/Attributes.scala
@@ -31,6 +31,7 @@ import pekko.actor.ActorSystem
import pekko.annotation.ApiMayChange
import pekko.annotation.DoNotInherit
import pekko.annotation.InternalApi
+import pekko.annotation.InternalStableApi
import pekko.event.Logging
import pekko.japi.function
import pekko.stream.impl.TraversalBuilder
@@ -303,25 +304,31 @@ final class Attributes private[pekko] (
}
/**
+ * INTERNAL API
+ *
* Java API: Get the least specific attribute (added first) of a given
`Class` or subclass thereof.
* If no such attribute exists the `default` value is returned.
*/
- @deprecated("Attributes should always be most specific, use
getAttribute[T]", "Akka 2.5.7")
+ @InternalStableApi
def getFirstAttribute[T <: Attribute](c: Class[T], default: T): T =
getFirstAttribute(c).orElse(default)
/**
+ * INTERNAL API
+ *
* Java API: Get the least specific attribute (added first) of a given
`Class` or subclass thereof.
*/
- @deprecated("Attributes should always be most specific, use get[T]", "Akka
2.5.7")
+ @InternalStableApi
def getFirstAttribute[T <: Attribute](c: Class[T]): Optional[T] =
attributeList.reverseIterator.collectFirst { case attr if
c.isInstance(attr) => c.cast(attr) }.toJava
/**
+ * INTERNAL API
+ *
* Scala API: Get the least specific attribute (added first) of a given type
parameter T `Class` or subclass thereof.
* If no such attribute exists the `default` value is returned.
*/
- @deprecated("Attributes should always be most specific, use get[T]", "Akka
2.5.7")
+ @InternalStableApi
def getFirst[T <: Attribute: ClassTag](default: T): T = {
getFirst[T] match {
case Some(a) => a
@@ -330,9 +337,11 @@ final class Attributes private[pekko] (
}
/**
+ * INTERNAL API
+ *
* Scala API: Get the least specific attribute (added first) of a given type
parameter T `Class` or subclass thereof.
*/
- @deprecated("Attributes should always be most specific, use get[T]", "Akka
2.5.7")
+ @InternalStableApi
def getFirst[T <: Attribute: ClassTag]: Option[T] = {
val c = classTag[T].runtimeClass.asInstanceOf[Class[T]]
attributeList.reverseIterator.collectFirst { case attr if
c.isInstance(attr) => c.cast(attr) }
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]