You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2026/06/25 20:32:18 UTC

[PR] refactor: migrate Collections/Arrays.asList to Java 9+ collection factories [pekko-http]

He-Pin opened a new pull request, #1089:
URL: https://github.com/apache/pekko-http/pull/1089

   ### Motivation
   Java 9+ provides `List.of()`, `Map.of()`, `Set.of()` factory methods that are more concise and return truly immutable collections.
   
   ### Modification
   - Replace `Arrays.asList(...)` with `List.of(...)` across 14 files
   - Replace `Collections.singletonList()` with `List.of()`, `Collections.emptyList/Map/Set()` with `List/Map/Set.of()`
   - Replace `new HashMap<>()` + `put()` chains with `Map.of()`
   - Replace `new HashSet<>(Arrays.asList(...))` with `Set.of(...)`
   - Correctly skips shaded `com.twitter.hpack` code and array-parameter conversions in `Util.java` and `MediaTypes.java`
   
   ### Result
   Cleaner code using Java 17 immutable collection factories. 20 files changed.
   
   ### Tests
   Not run - compile-only test file changes
   
   ### References
   None - Java 17 API modernization


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] refactor: migrate Collections/Arrays.asList to Java 9+ collection factories [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1089:
URL: https://github.com/apache/pekko-http/pull/1089#discussion_r3477542789


##########
http-core/src/main/java/org/apache/pekko/http/javadsl/model/MediaTypes.java:
##########
@@ -596,7 +596,7 @@ public static MediaType.Binary customBinary(
         mainType,
         subType,
         compressibility,
-        java.util.Collections.<String, String>emptyMap(),
+        java.util.Map.<String, String>of(),

Review Comment:
   I don't like the new map here, I prefer the singleton that we already use



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] refactor: migrate Collections/Arrays.asList to Java 9+ collection factories [pekko-http]

Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin merged PR #1089:
URL: https://github.com/apache/pekko-http/pull/1089


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org


Re: [PR] refactor: migrate Collections/Arrays.asList to Java 9+ collection factories [pekko-http]

Posted by "pjfanning (via GitHub)" <gi...@apache.org>.
pjfanning commented on code in PR #1089:
URL: https://github.com/apache/pekko-http/pull/1089#discussion_r3477538713


##########
http-core/src/main/java/org/apache/pekko/http/javadsl/model/Multiparts.java:
##########
@@ -109,7 +108,7 @@ public static Multipart.FormData.BodyPart createFormDataPartFromPath(
   public static Multipart.FormData.BodyPart createFormDataBodyPart(
       String name, BodyPartEntity entity) {
     List nil = Nil$.MODULE$;
-    Map<String, String> additionalDispositionParams = Collections.emptyMap();

Review Comment:
   I prefer Collections.emptyMap() - does not create a new map



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org