-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed as not planned
Labels
staleStale issue or pull request which will be closed soonStale issue or pull request which will be closed soon
Description
Kind: probably Bug
dw-Version: 4.0.6
I have the following scenario:
During runtime, I want to create and remove HttpClients. The name under which the clients are created are derived from user input.
This works fine until a new client is created with a name of a former (already closed) client.
Test
package some.package;
import jakarta.ws.rs.client.Client;
import io.dropwizard.client.JerseyClientBuilder;
import io.dropwizard.core.setup.Environment;
import org.junit.jupiter.api.Test;
public class ClientTest {
@Test
void test() {
Environment environment = new Environment("test");
Client client = new JerseyClientBuilder(environment).build("some-id");
client.close();
Client newClient = new JerseyClientBuilder(environment).build("some-id"); // This fails
}
}The test throws this exception:
java.lang.IllegalArgumentException: A metric named org.apache.hc.client5.http.io.HttpClientConnectionManager.some-id.available-connections already exists
at com.codahale.metrics.MetricRegistry.register(MetricRegistry.java:168)
at com.codahale.metrics.MetricRegistry.registerGauge(MetricRegistry.java:88)
at com.codahale.metrics.httpclient5.InstrumentedHttpClientConnectionManager.<init>(InstrumentedHttpClientConnectionManager.java:55)
at com.codahale.metrics.httpclient5.InstrumentedHttpClientConnectionManager$Builder.build(InstrumentedHttpClientConnectionManager.java:168)
at io.dropwizard.client.HttpClientBuilder.createConnectionManager(HttpClientBuilder.java:484)
at io.dropwizard.client.HttpClientBuilder.buildWithDefaultRequestConfiguration(HttpClientBuilder.java:301)
at io.dropwizard.client.JerseyClientBuilder.buildConfig(JerseyClientBuilder.java:401)
at io.dropwizard.client.JerseyClientBuilder.build(JerseyClientBuilder.java:357)
at io.dropwizard.client.JerseyClientBuilder.build(JerseyClientBuilder.java:347)
at com.bakdata.conquery.models.forms.ClientTest.test(ClientTest.java:19)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
I'm not sure if this is behavior is intended.
Workaround
I want to use this Client because of its metrics instrumentation.
I guess the only workaround currently is to manage the ConnectionProvider by myself and provide it to the JerseyClientBuilder.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
staleStale issue or pull request which will be closed soonStale issue or pull request which will be closed soon