diff --git a/jersey/pom.xml b/jersey/pom.xml index c8a7de66ae..7c7330d84f 100644 --- a/jersey/pom.xml +++ b/jersey/pom.xml @@ -72,6 +72,11 @@ ${jersey.version} test + + org.glassfish.jersey.connectors + jersey-apache-connector + ${jersey.version} + @@ -95,7 +100,7 @@ - 2.26 + 2.38 \ No newline at end of file diff --git a/jersey/src/main/java/com/baeldung/jersey/client/JerseyClientHeaders.java b/jersey/src/main/java/com/baeldung/jersey/client/JerseyClientHeaders.java index ebcbe1d4ab..29db298e9e 100644 --- a/jersey/src/main/java/com/baeldung/jersey/client/JerseyClientHeaders.java +++ b/jersey/src/main/java/com/baeldung/jersey/client/JerseyClientHeaders.java @@ -1,6 +1,8 @@ package com.baeldung.jersey.client; import com.baeldung.jersey.client.filter.AddHeaderOnRequestFilter; +import org.glassfish.jersey.apache.connector.ApacheConnectorProvider; +import org.glassfish.jersey.client.ClientConfig; import org.glassfish.jersey.client.authentication.HttpAuthenticationFeature; import org.glassfish.jersey.client.oauth1.AccessToken; import org.glassfish.jersey.client.oauth1.ConsumerCredentials; @@ -155,7 +157,8 @@ public class JerseyClientHeaders { } public static Response sendRestrictedHeaderThroughDefaultTransportConnector(String headerKey, String headerValue) { - Client client = ClientBuilder.newClient(); + ClientConfig clientConfig = new ClientConfig().connectorProvider(new ApacheConnectorProvider()); + Client client = ClientBuilder.newClient(clientConfig); System.setProperty("sun.net.http.allowRestrictedHeaders", "true"); return client.target(TARGET) diff --git a/jersey/src/test/java/com/baeldung/jersey/server/EchoHeadersUnitTest.java b/jersey/src/test/java/com/baeldung/jersey/server/EchoHeadersUnitTest.java index cca7446dd1..24552f6d81 100644 --- a/jersey/src/test/java/com/baeldung/jersey/server/EchoHeadersUnitTest.java +++ b/jersey/src/test/java/com/baeldung/jersey/server/EchoHeadersUnitTest.java @@ -2,10 +2,8 @@ package com.baeldung.jersey.server; import com.baeldung.jersey.client.JerseyClientHeaders; import com.baeldung.jersey.client.filter.AddHeaderOnRequestFilter; -import org.glassfish.jersey.media.sse.SseFeature; import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.test.JerseyTest; -import org.junit.Ignore; import org.junit.Test; import javax.ws.rs.core.Application; @@ -17,7 +15,6 @@ import java.util.Map; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -@Ignore public class EchoHeadersUnitTest extends JerseyTest { private static final String SIMPLE_HEADER_KEY = "my-header-key";