Skip to content

Commit 3142298

Browse files
author
Adrian Cole
committed
Merge pull request OpenFeign#103 from wnagele/6.x
Fix for bug OpenFeign#85
2 parents 66c3ad9 + 0032df5 commit 3142298

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

CHANGES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### Version 6.1.2
2+
* Named query parameters on GET request result in POST request (bug #85)
3+
14
### Version 6.0.2
25
* Fix for BasicAuthRequestInterceptor when username and/or password are long.
36

core/src/main/java/feign/Contract.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.ArrayList;
2323
import java.util.Collection;
2424
import java.util.List;
25+
import java.util.Map;
2526

2627
import static feign.Util.checkState;
2728
import static feign.Util.emptyToNull;
@@ -165,14 +166,28 @@ protected boolean processAnnotationsOnParameter(MethodMetadata data, Annotation[
165166
checkState(emptyToNull(name) != null, "Named annotation was empty on param %s.", paramIndex);
166167
nameParam(data, name, paramIndex);
167168
isHttpAnnotation = true;
168-
if (data.template().url().indexOf('{' + name + '}') == -1 && //
169-
!(data.template().queries().containsKey(name)
170-
|| data.template().headers().containsKey(name))) {
169+
String varName = '{' + name + '}';
170+
if (data.template().url().indexOf(varName) == -1 &&
171+
!searchMapValues(data.template().queries(), varName) &&
172+
!searchMapValues(data.template().headers(), varName)) {
171173
data.formParams().add(name);
172174
}
173175
}
174176
}
175177
return isHttpAnnotation;
176178
}
179+
180+
private <K, V> boolean searchMapValues(Map<K, Collection<V>> map, V search) {
181+
Collection<Collection<V>> values = map.values();
182+
if (values == null)
183+
return false;
184+
185+
for (Collection<V> entry : values) {
186+
if (entry.contains(search))
187+
return true;
188+
}
189+
190+
return false;
191+
}
177192
}
178193
}

0 commit comments

Comments
 (0)