@@ -132,35 +132,34 @@ public Client getClient() {
132132 }
133133
134134 /**
135- * Build HTTP client used for requests
135+ * Build default HTTP client used for requests
136136 *
137- * @return initialized HTTP client
138- */
139- private Client buildClient () {
140- ClientBuilder clientBuilder = ClientBuilder .newBuilder ();
141- return clientBuilder .withConfig (clientConfig ()).build ();
142- }
143-
144- /** Jersey client uses HttpUrlConnection by default which doesn't have PATCH method:
137+ * Jersey client uses HttpUrlConnection by default which doesn't have PATCH method:
145138 * https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html#setRequestMethod-java.lang.String-
146139 * https://github.com/eclipse-ee4j/jersey/issues/4825
147140 *
148141 * Workaround for being able to do PATCH requests is by using reflection, which would work up to Java 16.
149142 * https://stackoverflow.com/questions/55778145/how-to-use-patch-method-with-jersey-invocation-builder
150143 *
151- * This workaround doesn't need to be set if custom connector like grizzly is used
152- * supported connector list can be seen here:
153- * https://www.cwiki.us/display/JERSEYEN/Client+Transport+Connectors
154- * https://eclipse-ee4j.github.io/jersey.github.io/documentation/latest/client.html#d0e4979
144+ * @return initialized HTTP client
145+ */
146+ private Client buildClient () {
147+ Client client = ClientBuilder .newClient ();
148+ // this allows calls to PATCH by using reflection
149+ client .property (HttpUrlConnectorProvider .SET_METHOD_WORKAROUND , true );
150+ return client ;
151+ }
152+
153+ /**
154+ * Build HTTP client with custom config used for requests
155+ * like:
155156 *
156- * @return client configuration which determines connection provider used by Jersey HTTP client.
157+ * ClientConfig clientConfig = new ClientConfig();
158+ * clientConfig.connectorProvider(new GrizzlyConnectorProvider());
159+ * clientConfig.connectorProvider(new HttpUrlConnectorProvider().useSetMethodWorkaround());
157160 */
158- private ClientConfig clientConfig () {
159- ClientConfig clientConfig = new ClientConfig ();
160- // use default provider, you can also use providers that support jdk 16+ like:
161- //clientConfig.connectorProvider(new GrizzlyConnectorProvider());
162- clientConfig .connectorProvider (new HttpUrlConnectorProvider ().useSetMethodWorkaround ());
163- return clientConfig ;
161+ private Client buildClient (ClientConfig config ) {
162+ return ClientBuilder .newClient (config );
164163 }
165164
166165 /**
0 commit comments