Take redirect count from CRP - 0 by default (#389)
This commit is contained in:
Родитель
a00bd15f43
Коммит
fb832817eb
|
@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
### Changed
|
||||
- [BREAKING] Redirects are disabled by default. Use ClientRequestProperties "client_max_redirect_count" option
|
||||
to enable. Default changed to 0.
|
||||
## [5.2.0] - 2024-08-27
|
||||
### Fixed
|
||||
- Used Msal user prompt old code which is deprecated in the new version coming from last bom update resulted in method not found exception.
|
||||
|
|
|
@ -362,11 +362,12 @@ class ClientImpl implements Client, StreamingClient {
|
|||
} catch (KustoClientInvalidConnectionStringException e) {
|
||||
throw new DataClientException(clusterUrl, e.getMessage(), e);
|
||||
}
|
||||
|
||||
// trace httpCall
|
||||
return MonitoredActivity.invoke(
|
||||
(SupplierTwoExceptions<InputStream, DataServiceException, DataClientException>) () -> HttpPostUtils.postToStreamingOutput(httpClient,
|
||||
clusterEndpoint,
|
||||
jsonPayload, timeoutMs + CLIENT_SERVER_DELTA_IN_MILLISECS, headers),
|
||||
jsonPayload, timeoutMs + CLIENT_SERVER_DELTA_IN_MILLISECS, headers, properties.getRedirectCount()),
|
||||
"ClientImpl.executeStreamingQuery", updateAndGetExecuteTracingAttributes(database, properties));
|
||||
}
|
||||
|
||||
|
|
|
@ -35,10 +35,13 @@ import java.util.regex.Pattern;
|
|||
* Such properties may be used to provide additional information to Kusto (for example, for the purpose of correlating client/service interaction),
|
||||
* may affect what limits and policies get applied to the request, and much more.
|
||||
* For a complete list of available client request properties
|
||||
* check out https://docs.microsoft.com/en-us/azure/kusto/api/netfx/request-properties#list-of-clientrequestproperties
|
||||
* check out https://docs.microsoft.com/azure/kusto/api/netfx/request-properties#list-of-clientrequestproperties
|
||||
*/
|
||||
public class ClientRequestProperties implements Serializable, TraceableAttributes {
|
||||
public static final String OPTION_SERVER_TIMEOUT = "servertimeout";
|
||||
|
||||
// If set and positive, indicates the maximum number of HTTP redirects that the client will process. [Integer]
|
||||
public static final String OPTION_CLIENT_MAX_REDIRECT_COUNT = "client_max_redirect_count";
|
||||
/*
|
||||
* Matches valid Kusto Timespans: Optionally negative, optional number of days followed by a period, optionally up to 24 as hours followed by a colon,
|
||||
* followed by up to 59 minutes (required), followed by up to 59 seconds (required), followed by optional subseconds prepended by a period. For example:
|
||||
|
@ -69,6 +72,21 @@ public class ClientRequestProperties implements Serializable, TraceableAttribute
|
|||
return options.get(name);
|
||||
}
|
||||
|
||||
public int getRedirectCount() {
|
||||
Object optionClientMaxRedirectOption = getOption(OPTION_CLIENT_MAX_REDIRECT_COUNT);
|
||||
int optionClientMaxRedirectCount = 0;
|
||||
if (optionClientMaxRedirectOption instanceof Integer) {
|
||||
optionClientMaxRedirectCount = (int) optionClientMaxRedirectOption;
|
||||
} else if (optionClientMaxRedirectOption instanceof String) {
|
||||
try {
|
||||
optionClientMaxRedirectCount = Integer.parseInt((String) optionClientMaxRedirectOption);
|
||||
} catch (NumberFormatException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
return Math.max(optionClientMaxRedirectCount, 0);
|
||||
}
|
||||
|
||||
public void removeOption(String name) {
|
||||
options.remove(name);
|
||||
}
|
||||
|
|
|
@ -255,4 +255,19 @@ class ClientRequestPropertiesTest {
|
|||
String result = new CslTimespanFormat(timeString).toString();
|
||||
Assertions.assertEquals("time(" + timeString + ")", result);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testRedirectCount() {
|
||||
ClientRequestProperties clientRequestProperties = new ClientRequestProperties();
|
||||
int redirectCount = clientRequestProperties.getRedirectCount();
|
||||
Assertions.assertEquals(0, redirectCount);
|
||||
|
||||
clientRequestProperties.setOption(ClientRequestProperties.OPTION_CLIENT_MAX_REDIRECT_COUNT, 1);
|
||||
redirectCount = clientRequestProperties.getRedirectCount();
|
||||
Assertions.assertEquals(1, redirectCount);
|
||||
|
||||
clientRequestProperties.setOption(ClientRequestProperties.OPTION_CLIENT_MAX_REDIRECT_COUNT, "1");
|
||||
redirectCount = clientRequestProperties.getRedirectCount();
|
||||
Assertions.assertEquals(1, redirectCount);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче