java-topology/defects/micronaut-core/patch/micronaut-core-0001-http-client-uri-variable-lookup.patch

37 lines
1.9 KiB
Diff

# UNDF: UNDF-2026-000000740
# UNDF: (leave blank)
--- a/http-client-core/src/main/java/io/micronaut/http/client/interceptor/HttpClientIntroductionAdvice.java
+++ b/http-client-core/src/main/java/io/micronaut/http/client/interceptor/HttpClientIntroductionAdvice.java
@@ -1,6 +1,7 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
@@ -377,7 +377,7 @@
List<Argument<?>> bodyArguments = new ArrayList<>();
- List<String> uriVariables = uriTemplate.getVariableNames();
+ Set<String> uriVariables = new HashSet<>(uriTemplate.getVariableNames());
Map<String, MutableArgumentValue<?>> parameters = context.getParameters();
- ClientArgumentRequestBinder<Object> defaultBinder = buildDefaultBinder(pathParams, bodyArguments);
+ ClientArgumentRequestBinder<Object> defaultBinder = buildDefaultBinder(pathParams, bodyArguments, uriVariables);
// Apply all the method binders
@@ -404,7 +404,7 @@
- bindPathParams(uriVariables, pathParams, body);
+ bindPathParams(new ArrayList<>(uriVariables), pathParams, body);
@@ -499,8 +499,8 @@
- private ClientArgumentRequestBinder<Object> buildDefaultBinder(Map<String, Object> pathParams, List<Argument<?>> bodyArguments) {
+ private ClientArgumentRequestBinder<Object> buildDefaultBinder(Map<String, Object> pathParams, List<Argument<?>> bodyArguments, Set<String> uriVariableNames) {
return (ctx, uriCtx, value, req) -> {
Argument<?> argument = ctx.getArgument();
- if (uriCtx.getUriTemplate().getVariableNames().contains(argument.getName())) {
+ if (uriVariableNames.contains(argument.getName())) {
String name = argument.getAnnotationMetadata().stringValue(Bindable.class)
.orElse(argument.getName());