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: 2 additions & 1 deletion core/src/test/java/feign/FeignTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,8 @@ public void ensureRetryerClonesItself() throws Exception {
.errorDecoder(new ErrorDecoder() {
@Override
public Exception decode(String methodKey, Response response) {
return new RetryableException(response.status(), "play it again sam!", HttpMethod.POST, null);
return new RetryableException(response.status(), "play it again sam!", HttpMethod.POST,
null);
}
}).target(TestInterface.class, "http://localhost:" + server.getPort());

Expand Down
12 changes: 4 additions & 8 deletions jaxrs/src/main/java/feign/jaxrs/JAXRSContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ protected boolean processAnnotationsOnParameter(MethodMetadata data,
String name = QueryParam.class.cast(parameterAnnotation).value();
checkState(emptyToNull(name) != null, "QueryParam.value() was empty on parameter %s",
paramIndex);
Collection<String> query = addTemplatedParam(data.template().queries().get(name), name);
String query = addTemplatedParam(name);
data.template().query(name, query);
nameParam(data, name, paramIndex);
isHttpParam = true;
} else if (annotationType == HeaderParam.class) {
String name = HeaderParam.class.cast(parameterAnnotation).value();
checkState(emptyToNull(name) != null, "HeaderParam.value() was empty on parameter %s",
paramIndex);
Collection<String> header = addTemplatedParam(data.template().headers().get(name), name);
String header = addTemplatedParam(name);
data.template().header(name, header);
nameParam(data, name, paramIndex);
isHttpParam = true;
Expand All @@ -179,11 +179,7 @@ protected boolean processAnnotationsOnParameter(MethodMetadata data,
}

// Not using override as the super-type's method is deprecated and will be removed.
protected Collection<String> addTemplatedParam(Collection<String> possiblyNull, String name) {
if (possiblyNull == null) {
possiblyNull = new ArrayList<String>();
}
possiblyNull.add(String.format("{%s}", name));
return possiblyNull;
private String addTemplatedParam(String name) {
return String.format("{%s}", name);
}
}
23 changes: 23 additions & 0 deletions jaxrs/src/test/java/feign/jaxrs/JAXRSContractTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package feign.jaxrs;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -394,6 +395,18 @@ public void methodPathWithoutLeadingSlashParsesCorrectly() throws Exception {
.hasUrl("/base/specific");
}


@Test
public void producesWithHeaderParamContainAllHeaders() throws Exception {
assertThat(parseAndValidateMetadata(MixedAnnotations.class, "getWithHeaders",
String.class, String.class, String.class)
.template())
.hasHeaders(entry("Accept", Arrays.asList("{Accept}", "application/json")))
.hasQueries(
entry("multiple", Arrays.asList("stuff", "{multiple}")),
entry("another", Collections.singletonList("{another}")));
}

interface Methods {

@POST
Expand Down Expand Up @@ -638,4 +651,14 @@ private MethodMetadata parseAndValidateMetadata(Class<?> targetType,
return contract.parseAndValidateMetadata(targetType,
targetType.getMethod(method, parameterTypes));
}

interface MixedAnnotations {

@GET
@Path("/api/stuff?multiple=stuff")
@Produces("application/json")
Response getWithHeaders(@HeaderParam("Accept") String accept,
@QueryParam("multiple") String multiple,
@QueryParam("another") String another);
}
}