Skip to content

Feign bug when use @RequestParam but not have value #1482

Closed
@924060929

Description

@924060929

The jar is spring-cloud-netflix-core-1.2.2.RELEASE-sources.jar

In the code org\springframework\cloud\netflix\feign\annotation\RequestParamParameterProcessor.java, the method "processArgument" treat @RequestParam param as Map when the value is empty, but in spring mvc, when @RequestParam's value is null, reflect the field name as the value. This diffrent action can make misunderstand.

As follows:

@Override
public boolean processArgument(AnnotatedParameterContext context,
		Annotation annotation) {
	RequestParam requestParam = ANNOTATION.cast(annotation);
	String name = requestParam.value();
	if (emptyToNull(name) != null) {
		context.setParameterName(name);

		MethodMetadata data = context.getMethodMetadata();
		Collection<String> query = context.setTemplateParameter(name,
				data.template().queries().get(name));
		data.template().query(name, query);
	} else {
		// supports `Map` types
		MethodMetadata data = context.getMethodMetadata();
		data.queryMapIndex(context.getParameterIndex());
	}
	return true;
}

Please fix it, :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions