diff --git a/CHANGES.md b/CHANGES.md index b2df3279..0260d220 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,6 @@ +### Version 6.1.2 +* Named query parameters on GET request result in POST request (bug #85) + ### Version 6.0.2 * Fix for BasicAuthRequestInterceptor when username and/or password are long. diff --git a/core/src/main/java/feign/Contract.java b/core/src/main/java/feign/Contract.java index 81324740..d9ac3bd1 100644 --- a/core/src/main/java/feign/Contract.java +++ b/core/src/main/java/feign/Contract.java @@ -22,6 +22,7 @@ import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.List; +import java.util.Map; import static feign.Util.checkState; import static feign.Util.emptyToNull; @@ -165,14 +166,28 @@ public interface Contract { checkState(emptyToNull(name) != null, "Named annotation was empty on param %s.", paramIndex); nameParam(data, name, paramIndex); isHttpAnnotation = true; - if (data.template().url().indexOf('{' + name + '}') == -1 && // - !(data.template().queries().containsKey(name) - || data.template().headers().containsKey(name))) { + String varName = '{' + name + '}'; + if (data.template().url().indexOf(varName) == -1 && + !searchMapValues(data.template().queries(), varName) && + !searchMapValues(data.template().headers(), varName)) { data.formParams().add(name); } } } return isHttpAnnotation; } + + private boolean searchMapValues(Map> map, V search) { + Collection> values = map.values(); + if (values == null) + return false; + + for (Collection entry : values) { + if (entry.contains(search)) + return true; + } + + return false; + } } }