Some changes to help with Spring Boot 1.4 compatibility

The jackson version needs to be explicit (not in parent potentially)
and there is a weirdness with @RequestMapping in Spring 4.3
This commit is contained in:
Dave Syer
2016-05-05 16:49:15 +01:00
parent 2aedd9b27b
commit 5de52b96f4
2 changed files with 18 additions and 12 deletions

View File

@@ -23,6 +23,7 @@
<bintray.package>netflix</bintray.package>
<main.basedir>${basedir}</main.basedir>
<netty.version>4.0.27.Final</netty.version>
<jackson.version>2.7.3</jackson.version>
<!-- Sonar -->
<surefire.plugin.version>2.19.1</surefire.plugin.version>

View File

@@ -43,20 +43,22 @@ import org.springframework.core.io.ResourceLoader;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import static feign.Util.checkState;
import static feign.Util.emptyToNull;
import static org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation;
import feign.Contract;
import feign.Feign;
import feign.MethodMetadata;
import feign.Param;
import static feign.Util.checkState;
import static feign.Util.emptyToNull;
import static org.springframework.core.annotation.AnnotatedElementUtils.findMergedAnnotation;
/**
* @author Spencer Gibb
*/
public class SpringMvcContract extends Contract.BaseContract implements ResourceLoaderAware {
public class SpringMvcContract extends Contract.BaseContract
implements ResourceLoaderAware {
private static final String ACCEPT = "Accept";
@@ -85,8 +87,7 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource
ConversionService conversionService) {
Assert.notNull(annotatedParameterProcessors,
"Parameter processors can not be null.");
Assert.notNull(conversionService,
"ConversionService can not be null.");
Assert.notNull(conversionService, "ConversionService can not be null.");
List<AnnotatedParameterProcessor> processors;
if (!annotatedParameterProcessors.isEmpty()) {
@@ -152,8 +153,12 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource
RequestMapping methodMapping = findMergedAnnotation(method, RequestMapping.class);
// HTTP Method
checkOne(method, methodMapping.method(), "method");
data.template().method(methodMapping.method()[0].name());
RequestMethod[] methods = methodMapping.method();
if (methods.length == 0) {
methods = new RequestMethod[] { RequestMethod.GET };
}
checkOne(method, methods, "method");
data.template().method(methods[0].name());
// path
checkAtMostOne(method, methodMapping.value(), "value");
@@ -228,7 +233,7 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource
if (isHttpAnnotation && data.indexToExpander().get(paramIndex) == null
&& this.conversionService.canConvert(
method.getParameterTypes()[paramIndex], String.class)) {
data.indexToExpander().put(paramIndex, expander);
data.indexToExpander().put(paramIndex, this.expander);
}
return isHttpAnnotation;
}
@@ -334,7 +339,7 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource
@Override
public Collection<String> setTemplateParameter(String name,
Collection<String> rest) {
Collection<String> rest) {
return addTemplatedParam(rest, name);
}
}
@@ -349,7 +354,7 @@ public class SpringMvcContract extends Contract.BaseContract implements Resource
@Override
public String expand(Object value) {
return conversionService.convert(value, String.class);
return this.conversionService.convert(value, String.class);
}
}