Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### Version 6.1.1
* Fix for #85

### Version 6.1.0
* Add [SLF4J](http://www.slf4j.org/) integration

Expand Down
21 changes: 18 additions & 3 deletions core/src/main/java/feign/Contract.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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;
Expand Down Expand Up @@ -165,14 +166,28 @@ protected boolean processAnnotationsOnParameter(MethodMetadata data, Annotation[
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) &&

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can rid adding another utility method by using something like..

// static import valuesOrEmpty
!valuesOrEmpty(data.template().queries()).contains(varName)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That won't work. valuesOrEmpty just searches the values of the given map. The requirement here is to search the values of the Collections inside the Collection. If anything we'd need to add a Utility method to "flatten" cascaded Collections and then do a search against that.

!searchMapValues(data.template().headers(), varName)) {
data.formParams().add(name);
}
}
}
return isHttpAnnotation;
}

private <K, V> boolean searchMapValues(Map<K, Collection<V>> map, V search) {
Collection<Collection<V>> values = map.values();
if (values == null)
return false;

for (Collection<V> entry : values) {
if (entry.contains(search))
return true;
}

return false;
}
}
}