Skip to content

Commit

Permalink
fixes #2209 update MrasHandler to set keepalive timeout to 10 seconds (
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu authored Apr 12, 2024
1 parent 4558d06 commit 19d6aa1
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,13 @@ private void invokeApi(HttpServerExchange exchange, String serviceHost, String r
}
// this a workaround to bypass the hostname verification in jdk11 http client.
Map<String, Object> tlsMap = (Map<String, Object>)ClientConfig.get().getMappedConfig().get(Http2Client.TLS);
final Properties props = System.getProperties();
if(tlsMap != null && !Boolean.TRUE.equals(tlsMap.get(TLSConfig.VERIFY_HOSTNAME))) {
final Properties props = System.getProperties();
props.setProperty("jdk.internal.httpclient.disableHostnameVerification", Boolean.TRUE.toString());
}
props.setProperty("jdk.httpclient.keepalive.timeout", "10");
props.setProperty("jdk.httpclient.connectionPoolSize", "10");

client = clientBuilder.build();
} catch (IOException e) {
logger.error("Cannot create HttpClient:", e);
Expand Down Expand Up @@ -367,10 +370,12 @@ private Result<TokenResponse> getAccessToken() throws Exception {
}
// this a workaround to bypass the hostname verification in jdk11 http client.
Map<String, Object> tlsMap = (Map<String, Object>)ClientConfig.get().getMappedConfig().get(Http2Client.TLS);
final Properties props = System.getProperties();
if(tlsMap != null && !Boolean.TRUE.equals(tlsMap.get(TLSConfig.VERIFY_HOSTNAME))) {
final Properties props = System.getProperties();
props.setProperty("jdk.internal.httpclient.disableHostnameVerification", Boolean.TRUE.toString());
}
props.setProperty("jdk.httpclient.keepalive.timeout", "10");
props.setProperty("jdk.httpclient.connectionPoolSize", "10");
client = clientBuilder.build();
} catch (IOException e) {
logger.error("Cannot create HttpClient:", e);
Expand Down Expand Up @@ -440,10 +445,13 @@ private Result<TokenResponse> getMicrosoftToken() throws Exception {
}
// this a workaround to bypass the hostname verification in jdk11 http client.
Map<String, Object> tlsMap = (Map<String, Object>)ClientConfig.get().getMappedConfig().get(Http2Client.TLS);
final Properties props = System.getProperties();
if(tlsMap != null && !Boolean.TRUE.equals(tlsMap.get(TLSConfig.VERIFY_HOSTNAME))) {
final Properties props = System.getProperties();
props.setProperty("jdk.internal.httpclient.disableHostnameVerification", Boolean.TRUE.toString());
}
props.setProperty("jdk.httpclient.keepalive.timeout", "10");
props.setProperty("jdk.httpclient.connectionPoolSize", "10");

clientMicrosoft = clientBuilder.build();
} catch (IOException e) {
logger.error("Cannot create HttpClient:", e);
Expand Down

0 comments on commit 19d6aa1

Please sign in to comment.