Jersey2: Do not reinitialize ClientConfig with default values when building HTTP Client (#20687)

* Do not reinitialize ClientConfig with default values when building HTTP Client

* Regenerate Jersey2/3 examples
This commit is contained in:
jheyens 2025-04-23 09:24:22 +02:00 committed by GitHub
parent 346231083f
commit a66dd20783
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
13 changed files with 140 additions and 62 deletions

View File

@ -694,6 +694,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1383,8 +1384,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1405,6 +1408,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1414,8 +1422,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -694,6 +694,7 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1383,8 +1384,10 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1405,6 +1408,11 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1414,8 +1422,6 @@ public class ApiClient{{#jsr310}} extends JavaTimeFormatter{{/jsr310}} {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -473,6 +473,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1139,8 +1140,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1161,6 +1164,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1170,8 +1178,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -473,6 +473,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1139,8 +1140,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1161,6 +1164,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1170,8 +1178,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -614,6 +614,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1296,8 +1297,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1318,6 +1321,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1327,8 +1335,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -614,6 +614,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1296,8 +1297,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1318,6 +1321,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1327,8 +1335,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -473,6 +473,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1139,8 +1140,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1161,6 +1164,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1170,8 +1178,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -696,6 +696,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1378,8 +1379,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1400,6 +1403,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1409,8 +1417,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -522,6 +522,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1188,8 +1189,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1210,6 +1213,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1219,8 +1227,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -473,6 +473,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1139,8 +1140,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1161,6 +1164,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1170,8 +1178,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -598,6 +598,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1280,8 +1281,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1302,6 +1305,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1311,8 +1319,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -598,6 +598,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1280,8 +1281,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1302,6 +1305,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1311,8 +1319,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**

View File

@ -696,6 +696,7 @@ public class ApiClient extends JavaTimeFormatter {
*/
public ApiClient setDebugging(boolean debugging) {
this.debugging = debugging;
applyDebugSetting(this.clientConfig);
// Rebuild HTTP Client according to the new "debugging" value.
this.httpClient = buildHttpClient();
return this;
@ -1378,8 +1379,10 @@ public class ApiClient extends JavaTimeFormatter {
* @return Client
*/
protected Client buildHttpClient() {
// recreate the client config to pickup changes
// Create ClientConfig if it has not been initialized yet
if (clientConfig == null) {
clientConfig = getDefaultClientConfig();
}
ClientBuilder clientBuilder = ClientBuilder.newBuilder();
clientBuilder = clientBuilder.withConfig(clientConfig);
@ -1400,6 +1403,11 @@ public class ApiClient extends JavaTimeFormatter {
clientConfig.property(HttpUrlConnectorProvider.SET_METHOD_WORKAROUND, true);
// turn off compliance validation to be able to send payloads with DELETE calls
clientConfig.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
applyDebugSetting(clientConfig);
return clientConfig;
}
private void applyDebugSetting(ClientConfig clientConfig) {
if (debugging) {
clientConfig.register(new LoggingFeature(java.util.logging.Logger.getLogger(LoggingFeature.DEFAULT_LOGGER_NAME), java.util.logging.Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, 1024*50 /* Log payloads up to 50K */));
clientConfig.property(LoggingFeature.LOGGING_FEATURE_VERBOSITY, LoggingFeature.Verbosity.PAYLOAD_ANY);
@ -1409,8 +1417,6 @@ public class ApiClient extends JavaTimeFormatter {
// suppress warnings for payloads with DELETE calls:
java.util.logging.Logger.getLogger("org.glassfish.jersey.client").setLevel(java.util.logging.Level.SEVERE);
}
return clientConfig;
}
/**