You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2024/10/29 16:57:58 UTC
(httpcomponents-core) 01/02: Replace package-private static class with a method returning a lambda
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-core.git
commit 230ab3c0d86eb1abb8d8130956cb78c583a7911b
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Tue Oct 29 11:00:50 2024 -0400
Replace package-private static class with a method returning a lambda
- The class was package-private so I made the method also
package-private
- The method could be private
- The method being final allows the JVM the option to inline it at
runtime
---
.../org/apache/hc/core5/http/impl/routing/RequestRouter.java | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/routing/RequestRouter.java b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/routing/RequestRouter.java
index b0d27c89d..b58190109 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/http/impl/routing/RequestRouter.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/http/impl/routing/RequestRouter.java
@@ -103,13 +103,8 @@ public class RequestRouter<T> implements HttpRequestMapper<T> {
}
- static class NoAuthorityResolver<T> implements Function<URIAuthority, T> {
-
- @Override
- public T apply(final URIAuthority authority) {
- return null;
- }
-
+ static final <T> Function<URIAuthority, T> noAuthorityResolver() {
+ return u -> null;
}
@Internal
@@ -136,7 +131,7 @@ public class RequestRouter<T> implements HttpRequestMapper<T> {
}))));
final Function<URIAuthority, Function<String, T>> authorityFunction;
if (authorityMap.isEmpty()) {
- authorityFunction = new NoAuthorityResolver<>();
+ authorityFunction = noAuthorityResolver();
} else if (authorityMap.size() == 1) {
final Map.Entry<URIAuthority, Function<String, T>> entry = authorityMap.entrySet().iterator().next();
authorityFunction = new SingleAuthorityResolver<>(entry.getKey(), entry.getValue());