Fault tolerance @Asynchronous on MicroProfile REST client cause open liberty core dump on windows

395 views Asked by At

Fault tolerance @Asynchronous-annotation on a REST client cause a core dump on Windows and the following error on MacOS:

 *** java.lang.instrument ASSERTION FAILED ***: "!errorOutstanding" with message transform method call failed at ./src/java.instrument/share/native/libinstrument/JPLISAgent.c line: 873

Affected version: (Open Liberty 20.0.0.6/wlp-1.0.41.cl200620200528-0414) on OpenJDK 64-Bit Server VM, version 11.0.8+10-LTS

Used features:

[appSecurity-3.0, beanValidation-2.0, cdi-2.0, concurrent-1.0, distributedMap-1.0, ejbLite-3.2, el-3.0, jaxb-2.2, jaxrs-2.1, jaxrsClient-2.1, jdbc-4.2, jndi-1.0, jpa-2.2, jpaContainer-2.2, json-1.0, jsonb-1.0, jsonp-1.1, monitor-1.0, mpConfig-1.4, mpFaultTolerance-2.1, mpHealth-2.2, mpMetrics-2.3, mpOpenAPI-1.1, mpRestClient-1.4, requestTiming-1.0, servlet-4.0, ssl-1.0, transportSecurity-1.0].

To re-produce:

@ApplicationScoped
@RegisterRestClient(baseUri = "https://postman-echo.com")
public interface TestingClient {

@GET
@Asynchronous
@Path("delay/4")
@Consumes(value = MediaType.APPLICATION_JSON)
CompletionStage<Response> doesItCrashWithDelay(String dummyData);

Inject it:

@Inject
@RestClient
private TestingClient testingClient;

Use it:

@GET
@Path("doesitcrash")
public void doesItCrash() {
    final Response response = testingClient.doesItCrashWithDelay("dummydata").toCompletableFuture().join();
    logger.info(response.readEntity(String.class));
}

Workaround is to have another CDI bean invoking the rest client which have the fault tolerance annotations. But according to this blog post the REST client interface should be able to have fault tolerance annotations: https://openliberty.io/blog/2020/06/04/asynchronous-programming-microprofile-fault-tolerance.html

Are @Asynchronous allowed on REST client that is already async due to CompletionStage? As mentioned, all other annotations like @Timeout and @Retry seems to work.

1

There are 1 answers

1
Andy McCright On BEST ANSWER

First, you are 100% correct that you don't need the @Asynchronous annotation on the MP Rest Client interface method - per the MP Rest Client specification, a return type of CompletionStage makes it asynchronous. If you remove the @Asynchronous annotation, it should work.

While investigating the JVM error message, I came across this helpful post that indicates that this message means the JVM encountered a super large exception - probably a StackOverflowError. My guess is that the error occurred because there are now two different asynchronous mechanisms (MP Rest Client and MP Fault Tolerance) playing together - and probably not playing nicely. Without seeing the exception stack trace, we won't know for sure.

I would first suggest removing the annotation and verifying that that works - that is probably a better workaround than using a separate CDI bean. Next, I would suggest opening an issue at https://github.com/OpenLiberty/open-liberty/issues to investigate a better overall solution.