RestEasy client freezes with custom httpEngine

28 views Asked by At

I have a RestEasy client that I want to set NoConnectionReuseStrategy to. For this purpose, I create a custom instance of ApacheHttpClient43Engine with the desired settings.

However, when I make several requests one after the other, the application freezes (the request is sent to the server, but no response is received).

    private static final ResteasyClient RESTEASY_CLIENT;

    static {
        CloseableHttpClient httpClient = HttpClients.custom()
                                                .setConnectionManager(new PoolingHttpClientConnectionManager())
                                                .setConnectionReuseStrategy(new NoConnectionReuseStrategy())
                                                .build();

        ApacheHttpClientEngine engine = new ApacheHttpClient43Engine(httpClient);

        RESTEASY_CLIENT = ((ResteasyClientBuilder) ClientBuilder.newBuilder())
                .httpEngine(engine)
                .connectTimeout(1, TimeUnit.SECONDS)
                .readTimeout(1, TimeUnit.SECONDS)
                .build();

//        RESTEASY_CLIENT = (ResteasyClient) ClientBuilder.newClient();
        System.out.println(RESTEASY_CLIENT.httpEngine());

        RESTEASY_CLIENT.register(new BasicAuthentication(SERVER_USERNAME, SERVER_PASSWORD));
        RESTEASY_CLIENT.register(new AuthorizationFilter());
        RESTEASY_CLIENT.register(new LoggerFilter());
    }

Setting a timeout does not throw an exception or change behavior
In case I use

    private static final ResteasyClient RESTEASY_CLIENT;

    static {
        CloseableHttpClient httpClient = HttpClients.custom()
                                                .setConnectionManager(new PoolingHttpClientConnectionManager())
                                                .setConnectionReuseStrategy(new NoConnectionReuseStrategy())
                                                .build();

        ApacheHttpClientEngine engine = new ApacheHttpClient43Engine(httpClient);

//        RESTEASY_CLIENT = ((ResteasyClientBuilder) ClientBuilder.newBuilder())
//                .httpEngine(engine)
//                .connectTimeout(1, TimeUnit.SECONDS)
//                .readTimeout(1, TimeUnit.SECONDS)
//                .build();

        RESTEASY_CLIENT = (ResteasyClient) ClientBuilder.newClient();
        System.out.println(RESTEASY_CLIENT.httpEngine());

        RESTEASY_CLIENT.register(new BasicAuthentication(SERVER_USERNAME, SERVER_PASSWORD));
        RESTEASY_CLIENT.register(new AuthorizationFilter());
        RESTEASY_CLIENT.register(new LoggerFilter());
    }

The problem disappears
In both cases, the trace message from println outputs

org.jboss.resteasy.client.jaxrs.engines.ApacheHttpClient43

0

There are 0 answers