Update SIPHeaderList to inherit SequencedCollection added in OpenJDK 21
java.util.List now extends SequencedCollection interface. java language
doesn't allow overloading a super-interface's method with
an incompatible return type.
In order to expose SequencedCollection API in the build time,
SIPHeaderList needs to be updated to return a compatible return type.
Issue: FP3-A13#318
Bug: 320460092
Bug: 346585466
Test: m droid
(cherry picked from https://android-review.googlesource.com/q/commit:ed499e64f2e8ac0cc3f7c8fbc87c1b28fb4fc185)
(cherry picked from https://android-review.googlesource.com/q/commit:c6e1674b95d19603d479b4b0555768f2524054a0)
Merged-In: Iea134996c36b670964c614a01e1f2cb26a76082e
Change-Id: Iea134996c36b670964c614a01e1f2cb26a76082e
(cherry picked from commit 5cc92755a2de0cf9c0f4fc50d9d677e5432c3f64)
diff --git a/java/gov/nist/javax/sip/header/SIPHeaderList.java b/java/gov/nist/javax/sip/header/SIPHeaderList.java
index d11506a..f248303 100644
--- a/java/gov/nist/javax/sip/header/SIPHeaderList.java
+++ b/java/gov/nist/javax/sip/header/SIPHeaderList.java
@@ -208,7 +208,7 @@
*
* @return SIPHeader first element of the list.
*/
- public Header getFirst() {
+ public HDR getFirst() {
if (hlist == null || hlist.isEmpty())
return null;
else
@@ -220,7 +220,7 @@
*
* @return SIPHeader last element of the list.
*/
- public Header getLast() {
+ public HDR getLast() {
if (hlist == null || hlist.isEmpty())
return null;
return hlist.get(hlist.size() - 1);
@@ -277,18 +277,21 @@
/**
* Remove the first element of this list.
*/
- public void removeFirst() {
- if (hlist.size() != 0)
- hlist.remove(0);
-
+ public HDR removeFirst() {
+ if (hlist.size() != 0) {
+ return hlist.remove(0);
+ }
+ return null;
}
/**
* Remove the last element of this list.
*/
- public void removeLast() {
- if (hlist.size() != 0)
- hlist.remove(hlist.size() - 1);
+ public HDR removeLast() {
+ if (hlist.size() != 0) {
+ return hlist.remove(hlist.size() - 1);
+ }
+ return null;
}
/**