InaccessibleObjectException with CompletableFuture on JDK16
Open
Nobody has claimed this yet.
feedback provided
- Dominant language
- Java
- Stars
- 9.8k
- Forks
- 1.9k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 41
Description
Using a basic interface :
public interface SomeResourceClient {
@RequestLine("GET /resources")
CompletableFuture<SomeResource> all();
}
With a basic configuration :
@Configuration
public class FeignConfig {
@Bean
public SomeResourceClient zeltyRoomClient(Gson gson) {
return AsyncFeign.builder()
.client(new OkHttpClient())
.encoder(new GsonEncoder(gson))
.decoder(new GsonDecoder(gson))
.target(SomeResourceClient.class, "https://api.example.org/2.4");
}
}
I have an exception on runtime with JDK 16 :
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field volatile java.lang.Object java.util.concurrent.CompletableFuture.result accessible: module java.base does not "opens java.util.concurrent" to unnamed module @6895a785
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:357)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
at java.base/java.lang.reflect.Field.checkCanSetAccessible(Field.java:177)
at java.base/java.lang.reflect.Field.setAccessible(Field.java:171)
at com.google.gson.internal.reflect.UnsafeReflectionAccessor.makeAccessible(UnsafeReflectionAccessor.java:44)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:159)
at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:102)
at com.google.gson.Gson.getAdapter(Gson.java:458)
at com.google.gson.Gson.fromJson(Gson.java:931)
at com.google.gson.Gson.fromJson(Gson.java:897)
at feign.gson.GsonDecoder.decode(GsonDecoder.java:50)
at feign.AsyncResponseHandler.decode(AsyncResponseHandler.java:115)
... 72 more
Everything works perfectly without the CompletableFuture.
Is async calls supported on JDK16 ?
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 by reproducing the provided AsyncFeign configuration on JDK 16 and follow the stack trace through feign.gson.GsonDecoder and feign.AsyncResponseHandler into Gson's CompletableFuture handling. Compare the async and non-async cases, then verify whether the async call works without InaccessibleObjectException; the result should include a regression test or a clearly documented compatibility outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100