Attempt to submit a form using Map<String, String> results in EncodeException
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.8k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 41
Description
One of our Feign clients looked like:
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@FeignClient(name = "authClient", url = "${auth.url}", configuration = AuthClient.Configuration.class)
public interface AuthClient {
@PostMapping(value = "/oauth2/token", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
AuthResponse getAccessToken(@RequestBody Map<String, ?> request);
}
This works. However, changing request type from Map<String, ?> to Map<String, String> causes Feign to fail with:
feign.codec.EncodeException Unable to make field transient java.util.HashMap$Node[] java.util.HashMap.table accessible: module java.base does not "opens java.util" to unnamed module @531be3c5
During my investigation, I learned about Feign's close relationship with Map<String, ?> via feign.codec.Encoder#MAP_STRING_WILDCARD, but even if this is not a bug, but a design choice, it just seems like it should be handled more gracefully.
io.github.openfeign:feign-core:12.5
io.github.openfeign:feign-okhttp:13.2.1
io.github.openfeign.form:feign-form:3.8.0
io.github.openfeign.form:feign-form-spring:3.8.0
io.github.openfeign:feign-slf4j:12.5
org.springframework.cloud:spring-cloud-starter-openfeign:4.0.6
OpenJDK 21
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at feign.codec.Encoder#MAP_STRING_WILDCARD and reproduce the form submission with Map<String, String> on OpenJDK 21 using the dependency versions listed. Trace the encoder path that reaches the reported HashMap reflection error, then add or update coverage so this request type is handled gracefully without EncodeException.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100