Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0269f52
Adding changes for vectorIndex and vectorEmbeddingPolicy
aayush3011 Mar 22, 2024
29ad391
Adding some necessary comments
aayush3011 Mar 27, 2024
cd4d8cf
Adding test case
aayush3011 Mar 28, 2024
a2f6a83
updating enum values
aayush3011 Mar 28, 2024
c4bc283
Updating test case
aayush3011 Mar 28, 2024
af99d7b
Updating test case
aayush3011 Mar 29, 2024
6d8fc9b
Updating test case
aayush3011 Mar 29, 2024
2f7112d
updating changelog
aayush3011 Mar 29, 2024
158880f
Merge branch 'main' into users/akataria/vectorindexing
aayush3011 Mar 29, 2024
bb85dd3
Updating test case
aayush3011 Mar 29, 2024
a7185d7
Merge branch 'users/akataria/vectorindexing' of https://github.com/aa…
aayush3011 Mar 29, 2024
f4c4012
Merge branch 'Azure:main' into users/akataria/vectorindexing
aayush3011 Apr 2, 2024
72a4bcd
Resolving comments
aayush3011 Apr 2, 2024
dfb3575
Resolving comments
aayush3011 Apr 2, 2024
67f51cb
Fixing test case
aayush3011 Apr 2, 2024
730f8c2
Resolving comments
aayush3011 Apr 23, 2024
ad3ac89
Resolving Comments
aayush3011 Apr 27, 2024
940c6af
Merge branch 'main' into users/akataria/vectorindexing
aayush3011 Apr 27, 2024
3eb77ea
Fixing build issues
aayush3011 Apr 27, 2024
44f4e07
Merge branch 'main' into users/akataria/vectorindexing
aayush3011 Apr 29, 2024
460f681
Resolving comments
aayush3011 Apr 30, 2024
5579dd1
Resolving Comments
aayush3011 May 1, 2024
54a2ce3
Merge branch 'users/akataria/vectorindexing' of https://github.com/aa…
aayush3011 May 1, 2024
528a0eb
[Cosmos][VectorIndex]Adding changes for vectorIndex and vectorEmbeddi…
aayush3011 May 2, 2024
148cba5
[Cosmos][VectorSearch] Non Streaming Order By Query (#40085)
aayush3011 May 8, 2024
df7e838
[Cosmos][VectorSearch] Non Streaming Order By Query (#40096)
aayush3011 May 9, 2024
c8de52f
[Cosmos][VectorSearch] Non Streaming Order By Query (#40098)
aayush3011 May 9, 2024
425b78f
Merge branch 'Azure:main' into users/akataria/vectorindexing
aayush3011 May 10, 2024
55efb81
Resolving comments
aayush3011 May 10, 2024
9a3b003
Resolving comments
aayush3011 May 10, 2024
52917f9
[Cosmos][VectorSearch] Non Streaming Order By Query (#40115)
aayush3011 May 10, 2024
72a7145
Merge branch 'feature/vector_search' into users/akataria/vectorindexing
aayush3011 May 10, 2024
43f1d83
Merge branch 'Azure:main' into users/akataria/vectorindexing
aayush3011 May 12, 2024
fd13d87
Merge branch 'Azure:main' into users/akataria/vectorindexing
aayush3011 May 14, 2024
4055fe8
Fixing merge issues
aayush3011 May 14, 2024
62931db
Fixing merge issues
aayush3011 May 14, 2024
f7f7d08
Fixing build
aayush3011 May 15, 2024
bce71de
Fixing build
aayush3011 May 15, 2024
0a0a26a
Merge branch 'main' into users/akataria/vectorindexing
aayush3011 May 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[Cosmos][VectorSearch] Non Streaming Order By Query (#40115)
* Initial changes

* Initial changes

* Increment versions for core releases (#40003)

Increment package versions for core releases

* Ensure ServiceBus session idle timeout fall back to retry-options::try-timeout (#39994)

* Added Alpha3 Java Media Streaming Events (#40002)

* Added Alpha3 Java Media Streaming Events

* updating readme to add the media streaming events to remove model

---------

Co-authored-by: Vinothini Dharmaraj <[email protected]>

* Update version of github-event-processor to 1.0.0-dev.20240502.2 (#40012)

Co-authored-by: James Suplizio <[email protected]>

* Prepare May 2024 Identity Release (#40006)

* Prepare Identity Broker May 2024 Release (#40014)

* Increment package versions for identity releases (#40015)

* [JobRouter] SDK Review updates (#40011)

* SDK Review updates

* Update auto-generated models

* Add customization

* Fix customization

* Update package

* Update tests

* Linting

* FixFaultInjectionRuleFailedToApplyPerPartitionInGatewayMode (#40005)

* fix fault injection rule failed to apply per partition in gateway mode

---------

Co-authored-by: annie-mac <[email protected]>

* azure-cosmos-test_1.0.0.beta.7Release (#40021)

* release azure-cosmos-test 1.0.0.beta.7
---------

Co-authored-by: annie-mac <[email protected]>

* Fixed existsById API in ReactiveCosmosTemplate (#40022)

* Fixed existsById API in ReactiveCosmosTemplate

* Added changelog

* Initial changes

* Initial changes

* Skip Recorded test and delete Event record until test proxy to work with Event recordings (#40029)

Co-authored-by: Min Woo Lee 🧊 <[email protected]>

* Fix invalid CODEOWNERS (#40032)

* Initial changes

* ServiceBus: fix session tracing (#39962)

* remove additional matrix

* Fix session processing and disposition instrumentation

* return matrix config

* review suggestions

* [Automation] Generate SDK based on TypeSpec 0.15.15 (#40048)

* [CODEOWNERS] Updates for org changes (#40049)

* [CODEOWNERS] Updates for org changes

The focus of these changes is to remove an individual who no longer is responsible for the products which their GH account is associated to.

* Move from using the docker image to java2docfx for docs validation (#39744)

* Move from using the docker image to java2docfx for docs validation

* Temporarily turn on docs processing for template libraries for testing

* Actually install the rex validation tool

* Fix the if not Test-Path statement

* Update java2docfx version and add a couple of diagnostics output lines

* Add missing close paren

* Ensure that Sort-Object always returns an array even if there's only one item

* add another piece of diagnostics output

* trying one more thing

* remove some diag, add other

* Remove the additional diagnostics, add permanent output message

* Invoke java -jar on java2docfx to show the help command to ensure the install is okay

* fiddling with the java -jar command

* Set the working directory to the java2docfx directory before executing the mvn dependency download

* Actually create the directory before trying to set location...oops

* Update rex validation to verify MAVEN_HOME is set

* Updates for Java PR 39875 which had changes from this PR that were more immediate

* Update java2docfx version

* remove check for MAVEN_HOME which was only for testing

* Update the version of java2docfx to test a fix

* Update version of java2docfx to 1.0.4

* revert template's ci.yml changes that were only necessary to test java2docfx

* owners (#39686)

* Use ClientLogger in testing output (#40010)

Use ClientLogger in testing output

* Fix null pointer exception and context usage (#40053)

* Rename AML to AzureMachineLearning (#40056)

* Fixed the Key Vault `test-resources.json` file to properly configure a deployment script for certificate creation. (#40037)

* Close response body in bearer policy (#40052)

* Running Prepare-Release for azure-messaging-servicebus 7.17.0 (#40058)

* mgmt, TypeSpec code generation pipeline (#39963)

* typespec generation pipeline

echo command

PR_TITLE

* generation typespec

Update generation.yml for Azure Pipelines

Update generation.yml for Azure Pipelines

Update generation.yml for Azure Pipelines

* remove typespec pipeline file

* fix pr title

* address comments

* Add codeowner linter owners (#39997)

* Update to ESRP task version that supports federated auth (#40059)

* Increment package versions for cosmos releases (#40031)

* Update azure-sdk-build-tools Repository Resource Refs in Yaml files (#39627)

* Add reduced embeddings sample to azure-search-documents (#40069)

* Add reduced embeddings sample

* Fix cspell

* Fix link

* Search May Preview Regen Updates (#40057)

* Search May Preview Regeneration
- Still need to add varargs convenience

* Removing ovveride statements from `setFields` for `VectorizableImageUrlQuery` and `VectorizableImageBinaryQuery`

* Removing ovveride statements from `setFields` for `VectorizableImageUrlQuery` and `VectorizableImageBinaryQuery`

* adding varargs

* Additional adjustments to FieldBuilder and Search Index Customizations

* Updating cspell.json

* Adjust `SearchScoreThreshold` customization
Re-enable code generation in CI

* Updates:

- Updated Cspell
- Rename `maxStoragePerIndex` property to `maxStoragePerIndexInBytes` in SearchServiceLimits
- Set `hybridSearch` property to be type `HybridSearch` in SearchRequest
- Add `hybridSearch` to SearchOptions and `SearchAsyncClient.createSearchRequest()`

* Adding Support and testing byte[] and List<byte> within field builder

* Fix linting

---------

Co-authored-by: alzimmermsft <[email protected]>

* Preparing Search May 2024 Beta Release (#40071)

* Preparing Search May 2024 Beta Release

* Preparing Search May 2024 Beta Release

* Resolving comments

* Fixing build issues

* eng, update autorest.java, improve error output in sdk automation (#40073)

* improve error output

* autorest.java 4.1.29

* Merge to main after spring cloud azure 4.18.0 released (#40075)

* Prepare for Spring Cloud Azure 4.18.0 release (#40063)

* update version client

* update version/changelog/readme

* update changelog

* Increment versions for spring releases (#40074)

* Increment package versions for spring releases

* Update version_client.txt

* Update pom.xml

---------

Co-authored-by: Muyao Feng <[email protected]>

---------

Co-authored-by: Azure SDK Bot <[email protected]>

* Miscellaneous Core performance improvements (#39552)

Miscellaneous Core performance improvements

* Increment package versions for search releases (#40072)

* Update io.fabric8:kubernetes-client (#40086)

5.12.3 -> 6.12.1

* Increment package versions for servicebus releases (#40094)

* Emit stable auto-instrumented otel metrics (#39960)

* Update otel metrics logic

* add runtime metrics

* adding a few metrics I forgot

* small correction

* Update

* Fix

* Update

* Delete pre-stable metrics

---------

Co-authored-by: Harsimar Kaur (from Dev Box) <[email protected]>

* [Key Vault] Added support for `/prerestore` and `/prebackup` endpoints in Backup clients (#39878)

* Updated `autorest.md` files in all swagger folders.

* Re-generated implementation code.

* Updated ServiceVersion expandable enums.

* Added public APIs for the new /prebacukp and /prerestore endpoints.

* Added tests.

* Refactored Backup client tests.

* Updated tests.

* Updated test recordings.

* Updated documentation and samples.

* Addressed PR feedback.

* Initial changes

* Prepare to release beta.22 (#40097)

* Fix template name (#40099)

* Fix template name

* Also install the rex validation tool

* Update partner release to use WIF (#40101)

* core mgmt, `SubResource` implements `JsonSerializable` to support azure-json (#40076)

* test

* implementation

* fix lint

* spotless:apply

* Update spring-reference and sync changelog (#40105)

* update spring-reference.yml

* update CHANGELOG.md

* Support per-call response timeout in all HttpClient implementations (#40017)

Support per-call response timeout in all HttpClient implementations

* Change how JavaType is resolved to support JsonSerializable better (#40112)

* Initial changes

* Fixes

---------

Co-authored-by: Azure SDK Bot <[email protected]>
Co-authored-by: Anu Thomas Chandy <[email protected]>
Co-authored-by: v-durgeshs <[email protected]>
Co-authored-by: Vinothini Dharmaraj <[email protected]>
Co-authored-by: James Suplizio <[email protected]>
Co-authored-by: Bill Wert <[email protected]>
Co-authored-by: williamzhao87 <[email protected]>
Co-authored-by: Annie Liang <[email protected]>
Co-authored-by: annie-mac <[email protected]>
Co-authored-by: Kushagra Thapar <[email protected]>
Co-authored-by: minwoolee-msft <[email protected]>
Co-authored-by: Min Woo Lee 🧊 <[email protected]>
Co-authored-by: Alan Zimmer <[email protected]>
Co-authored-by: Liudmila Molkova <[email protected]>
Co-authored-by: Jesse Squire <[email protected]>
Co-authored-by: Harsimar Kaur <[email protected]>
Co-authored-by: vcolin7 <[email protected]>
Co-authored-by: Xiaofei Cao <[email protected]>
Co-authored-by: Wes Haggard <[email protected]>
Co-authored-by: Patrick Hallisey <[email protected]>
Co-authored-by: Jair Myree <[email protected]>
Co-authored-by: Weidong Xu <[email protected]>
Co-authored-by: Muyao Feng <[email protected]>
Co-authored-by: Helen <[email protected]>
Co-authored-by: Harsimar Kaur (from Dev Box) <[email protected]>
  • Loading branch information
commit 52917f935fdf16342d66da19fb831fa45fb16477
4 changes: 3 additions & 1 deletion eng/pipelines/docindex.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ jobs:
parameters:
DailyBranchVariableName: DailyDocsBranchName

- template: /eng/pipelines/templates/steps/mvn-linux-settings-for-docs.yml
- template: /eng/pipelines/templates/steps/mvn-linux-repository-settings.yml

- template: /eng/pipelines/templates/steps/install-rex-validation-tool.yml

- task: Powershell@2
inputs:
Expand Down
18 changes: 13 additions & 5 deletions eng/pipelines/partner-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ extends:

- template: /eng/pipelines/templates/steps/download-credscan-suppressions.yml

- task: PowerShell@2
displayName: 'Download packages from blob storage'
- task: AzurePowerShell@5
displayName: 'Copy from azuresdkpartnerdrops'
condition: and(succeeded(), ne(variables['SkipCopyFromPartnerDrops'], 'true'))
inputs:
targetType: filePath
filePath: '$(BuildToolScripts)/copy-from-azuresdkpartnerdrops.ps1'
arguments: '$(Artifacts) ${{ parameters.BlobPath }} $(azuresdkpartnerdrops-access-key)'
azureSubscription: 'azuresdkpartnerdrops - Storage Partner Drops'
ScriptType: 'InlineScript'
azurePowerShellVersion: LatestVersion
pwsh: true
Inline: |
azcopy copy 'https://azuresdkpartnerdrops.blob.core.windows.net/drops/${{ parameters.BlobPath }}/*' '$(Artifacts)' --recursive=true
echo "Copied files:"
dir '$(Artifacts)' -r | % { $_.FullName }
env:
AZCOPY_AUTO_LOGIN_TYPE: 'PSCRED'

- template: tools/java-esrp-signing/java-esrp-signing.yml@azure-sdk-build-tools
parameters:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import com.azure.core.http.jdk.httpclient.implementation.InputStreamTimeoutResponseSubscriber;
import com.azure.core.http.jdk.httpclient.implementation.JdkHttpResponseAsync;
import com.azure.core.http.jdk.httpclient.implementation.JdkHttpResponseSync;
import com.azure.core.implementation.util.HttpUtils;
import com.azure.core.util.Context;
import com.azure.core.util.logging.ClientLogger;
import reactor.core.publisher.Mono;
Expand All @@ -31,8 +32,6 @@
*/
class JdkHttpClient implements HttpClient {
private static final ClientLogger LOGGER = new ClientLogger(JdkHttpClient.class);
private static final String AZURE_EAGERLY_READ_RESPONSE = "azure-eagerly-read-response";
private static final String AZURE_IGNORE_RESPONSE_BODY = "azure-ignore-response-body";

private final java.net.http.HttpClient jdkHttpClient;

Expand Down Expand Up @@ -79,8 +78,8 @@ public Mono<HttpResponse> send(HttpRequest request) {

@Override
public Mono<HttpResponse> send(HttpRequest request, Context context) {
boolean eagerlyReadResponse = (boolean) context.getData(AZURE_EAGERLY_READ_RESPONSE).orElse(false);
boolean ignoreResponseBody = (boolean) context.getData(AZURE_IGNORE_RESPONSE_BODY).orElse(false);
boolean eagerlyReadResponse = (boolean) context.getData(HttpUtils.AZURE_EAGERLY_READ_RESPONSE).orElse(false);
boolean ignoreResponseBody = (boolean) context.getData(HttpUtils.AZURE_IGNORE_RESPONSE_BODY).orElse(false);

Mono<java.net.http.HttpRequest> jdkRequestMono = Mono.fromCallable(() -> toJdkHttpRequest(request, context));

Expand Down Expand Up @@ -111,8 +110,8 @@ public Mono<HttpResponse> send(HttpRequest request, Context context) {

@Override
public HttpResponse sendSync(HttpRequest request, Context context) {
boolean eagerlyReadResponse = (boolean) context.getData(AZURE_EAGERLY_READ_RESPONSE).orElse(false);
boolean ignoreResponseBody = (boolean) context.getData(AZURE_IGNORE_RESPONSE_BODY).orElse(false);
boolean eagerlyReadResponse = (boolean) context.getData(HttpUtils.AZURE_EAGERLY_READ_RESPONSE).orElse(false);
boolean ignoreResponseBody = (boolean) context.getData(HttpUtils.AZURE_IGNORE_RESPONSE_BODY).orElse(false);

java.net.http.HttpRequest jdkRequest = toJdkHttpRequest(request, context);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
import java.util.Set;
import java.util.concurrent.Executor;

import static com.azure.core.util.Configuration.PROPERTY_AZURE_REQUEST_CONNECT_TIMEOUT;
import static com.azure.core.util.Configuration.PROPERTY_AZURE_REQUEST_READ_TIMEOUT;
import static com.azure.core.util.Configuration.PROPERTY_AZURE_REQUEST_RESPONSE_TIMEOUT;
import static com.azure.core.util.Configuration.PROPERTY_AZURE_REQUEST_WRITE_TIMEOUT;
import static com.azure.core.util.CoreUtils.getDefaultTimeoutFromEnvironment;
import static com.azure.core.implementation.util.HttpUtils.getDefaultConnectTimeout;
import static com.azure.core.implementation.util.HttpUtils.getDefaultReadTimeout;
import static com.azure.core.implementation.util.HttpUtils.getDefaultResponseTimeout;
import static com.azure.core.implementation.util.HttpUtils.getDefaultWriteTimeout;
import static com.azure.core.implementation.util.HttpUtils.getTimeout;

/**
* Builder to configure and build an instance of the azure-core {@link HttpClient} type using the JDK HttpClient APIs,
Expand All @@ -38,12 +38,6 @@
public class JdkHttpClientBuilder {
private static final ClientLogger LOGGER = new ClientLogger(JdkHttpClientBuilder.class);

private static final Duration MINIMUM_TIMEOUT = Duration.ofMillis(1);
private static final Duration DEFAULT_CONNECTION_TIMEOUT;
private static final Duration DEFAULT_WRITE_TIMEOUT;
private static final Duration DEFAULT_RESPONSE_TIMEOUT;
private static final Duration DEFAULT_READ_TIMEOUT;

private static final String JAVA_HOME = System.getProperty("java.home");
private static final String JDK_HTTPCLIENT_ALLOW_RESTRICTED_HEADERS = "jdk.httpclient.allowRestrictedHeaders";

Expand All @@ -57,17 +51,6 @@ public class JdkHttpClientBuilder {
static final Set<String> DEFAULT_RESTRICTED_HEADERS;

static {
Configuration configuration = Configuration.getGlobalConfiguration();

DEFAULT_CONNECTION_TIMEOUT = getDefaultTimeoutFromEnvironment(configuration,
PROPERTY_AZURE_REQUEST_CONNECT_TIMEOUT, Duration.ofSeconds(10), LOGGER);
DEFAULT_WRITE_TIMEOUT = getDefaultTimeoutFromEnvironment(configuration, PROPERTY_AZURE_REQUEST_WRITE_TIMEOUT,
Duration.ofSeconds(60), LOGGER);
DEFAULT_RESPONSE_TIMEOUT = getDefaultTimeoutFromEnvironment(configuration,
PROPERTY_AZURE_REQUEST_RESPONSE_TIMEOUT, Duration.ofSeconds(60), LOGGER);
DEFAULT_READ_TIMEOUT = getDefaultTimeoutFromEnvironment(configuration, PROPERTY_AZURE_REQUEST_READ_TIMEOUT,
Duration.ofSeconds(60), LOGGER);

DEFAULT_RESTRICTED_HEADERS = Set.of("connection", "content-length", "expect", "host", "upgrade");
}

Expand Down Expand Up @@ -248,11 +231,11 @@ public HttpClient build() {
// Azure JDK http client supports HTTP 1.1 by default.
httpClientBuilder.version(java.net.http.HttpClient.Version.HTTP_1_1);

httpClientBuilder = httpClientBuilder.connectTimeout(getTimeout(connectionTimeout, DEFAULT_CONNECTION_TIMEOUT));
httpClientBuilder = httpClientBuilder.connectTimeout(getTimeout(connectionTimeout, getDefaultConnectTimeout()));

Duration writeTimeout = getTimeout(this.writeTimeout, DEFAULT_WRITE_TIMEOUT);
Duration responseTimeout = getTimeout(this.responseTimeout, DEFAULT_RESPONSE_TIMEOUT);
Duration readTimeout = getTimeout(this.readTimeout, DEFAULT_READ_TIMEOUT);
Duration writeTimeout = getTimeout(this.writeTimeout, getDefaultWriteTimeout());
Duration responseTimeout = getTimeout(this.responseTimeout, getDefaultResponseTimeout());
Duration readTimeout = getTimeout(this.readTimeout, getDefaultReadTimeout());

Configuration buildConfiguration
= (configuration == null) ? Configuration.getGlobalConfiguration() : configuration;
Expand Down Expand Up @@ -331,12 +314,4 @@ protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(this.userName, password.toCharArray());
}
}

private static Duration getTimeout(Duration configuredTimeout, Duration defaultTimeout) {
if (configuredTimeout == null) {
return defaultTimeout;
}

return configuredTimeout.compareTo(MINIMUM_TIMEOUT) < 0 ? MINIMUM_TIMEOUT : configuredTimeout;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.azure.core.http.HttpMethod;
import com.azure.core.implementation.util.HttpHeadersAccessHelper;
import com.azure.core.implementation.util.HttpUtils;
import com.azure.core.util.Context;
import com.azure.core.util.Contexts;
import com.azure.core.util.ProgressReporter;
Expand Down Expand Up @@ -51,6 +52,9 @@ public AzureJdkHttpRequest(com.azure.core.http.HttpRequest azureCoreRequest, Con
Set<String> restrictedHeaders, ClientLogger logger, Duration writeTimeout, Duration responseTimeout) {
HttpMethod method = azureCoreRequest.getHttpMethod();
ProgressReporter progressReporter = Contexts.with(context).getHttpRequestProgressReporter();
responseTimeout = (Duration) context.getData(HttpUtils.AZURE_RESPONSE_TIMEOUT)
.filter(timeoutDuration -> timeoutDuration instanceof Duration)
.orElse(responseTimeout);

this.method = method.toString();
this.bodyPublisher = (method == HttpMethod.GET || method == HttpMethod.HEAD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public final class JdkHttpClientLocalTestServer {
private static volatile LocalTestServer proxyServer;
private static final Semaphore PROXY_SERVER_SEMAPHORE = new Semaphore(1);

public static final String TIMEOUT = "/timeout";

public static final byte[] SHORT_BODY = "hi there".getBytes(StandardCharsets.UTF_8);
public static final byte[] LONG_BODY = createLongBody();

Expand Down Expand Up @@ -104,6 +106,16 @@ private static LocalTestServer initializeServer() {
resp.getHttpOutput().write(SHORT_BODY, 5, 3);
resp.getHttpOutput().flush();
resp.getHttpOutput().complete(Callback.NOOP);
} else if (get && TIMEOUT.equals(path)) {
try {
Thread.sleep(5000);
resp.setStatus(200);
resp.getHttpOutput().write(SHORT_BODY);
resp.getHttpOutput().flush();
resp.getHttpOutput().complete(Callback.NOOP);
} catch (InterruptedException e) {
throw new ServletException(e);
}
} else {
throw new ServletException("Unexpected request: " + req.getMethod() + " " + path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.azure.core.http.HttpMethod;
import com.azure.core.http.HttpRequest;
import com.azure.core.http.HttpResponse;
import com.azure.core.implementation.util.HttpUtils;
import com.azure.core.util.BinaryData;
import com.azure.core.util.Context;
import com.azure.core.util.Contexts;
Expand Down Expand Up @@ -55,6 +56,7 @@

import static com.azure.core.http.jdk.httpclient.JdkHttpClientLocalTestServer.LONG_BODY;
import static com.azure.core.http.jdk.httpclient.JdkHttpClientLocalTestServer.SHORT_BODY;
import static com.azure.core.http.jdk.httpclient.JdkHttpClientLocalTestServer.TIMEOUT;
import static com.azure.core.test.utils.TestUtils.assertArraysEqual;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertInstanceOf;
Expand Down Expand Up @@ -469,6 +471,46 @@ public void slowEagerReadingTimesOutAsync() {
.verify(Duration.ofSeconds(5));
}

@Test
public void perCallTimeout() {
HttpClient client = new JdkHttpClientBuilder().responseTimeout(Duration.ofSeconds(10)).build();

HttpRequest request = new HttpRequest(HttpMethod.GET, url(TIMEOUT));

// Verify a smaller timeout sent through Context times out the request.
StepVerifier.create(client.send(request, new Context(HttpUtils.AZURE_RESPONSE_TIMEOUT, Duration.ofSeconds(1))))
.expectErrorMatches(e -> e instanceof HttpTimeoutException)
.verify();

// Then verify not setting a timeout through Context does not time out the request.
StepVerifier.create(client.send(request)
.flatMap(response -> Mono.zip(FluxUtil.collectBytesInByteBufferStream(response.getBody()),
Mono.just(response.getStatusCode()))))
.assertNext(tuple -> {
assertArraysEqual(SHORT_BODY, tuple.getT1());
assertEquals(200, tuple.getT2());
})
.verifyComplete();
}

@Test
public void perCallTimeoutSync() {
HttpClient client = new JdkHttpClientBuilder().responseTimeout(Duration.ofSeconds(10)).build();

HttpRequest request = new HttpRequest(HttpMethod.GET, url(TIMEOUT));

// Verify a smaller timeout sent through Context times out the request.
RuntimeException ex = assertThrows(RuntimeException.class,
() -> client.sendSync(request, new Context(HttpUtils.AZURE_RESPONSE_TIMEOUT, Duration.ofSeconds(1))));
assertInstanceOf(HttpTimeoutException.class, ex.getCause());

// Then verify not setting a timeout through Context does not time out the request.
try (HttpResponse response = client.sendSync(request, Context.NONE)) {
assertEquals(200, response.getStatusCode());
assertArraysEqual(SHORT_BODY, response.getBodyAsBinaryData().toBytes());
}
}

private static Mono<HttpResponse> getResponse(String path) {
HttpClient client = new JdkHttpClientBuilder().build();
return doRequest(client, path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.azure.core.implementation.util.BinaryDataHelper;
import com.azure.core.implementation.util.ByteArrayContent;
import com.azure.core.implementation.util.FileContent;
import com.azure.core.implementation.util.HttpUtils;
import com.azure.core.implementation.util.InputStreamContent;
import com.azure.core.implementation.util.SerializableContent;
import com.azure.core.implementation.util.StringContent;
Expand Down Expand Up @@ -94,11 +95,6 @@ class NettyAsyncHttpClient implements HttpClient {
private static final ClientLogger LOGGER = new ClientLogger(NettyAsyncHttpClient.class);
private static final byte[] EMPTY_BYTES = new byte[0];

private static final String AZURE_EAGERLY_READ_RESPONSE = "azure-eagerly-read-response";
private static final String AZURE_IGNORE_RESPONSE_BODY = "azure-ignore-response-body";
private static final String AZURE_RESPONSE_TIMEOUT = "azure-response-timeout";
private static final String AZURE_EAGERLY_CONVERT_HEADERS = "azure-eagerly-convert-headers";

final boolean disableBufferCopy;

final boolean addProxyHandler;
Expand Down Expand Up @@ -132,10 +128,11 @@ public Mono<HttpResponse> send(HttpRequest request, Context context) {
Objects.requireNonNull(request.getUrl(), "'request.getUrl()' cannot be null.");
Objects.requireNonNull(request.getUrl().getProtocol(), "'request.getUrl().getProtocol()' cannot be null.");

boolean eagerlyReadResponse = (boolean) context.getData(AZURE_EAGERLY_READ_RESPONSE).orElse(false);
boolean ignoreResponseBody = (boolean) context.getData(AZURE_IGNORE_RESPONSE_BODY).orElse(false);
boolean headersEagerlyConverted = (boolean) context.getData(AZURE_EAGERLY_CONVERT_HEADERS).orElse(false);
Long responseTimeout = context.getData(AZURE_RESPONSE_TIMEOUT)
boolean eagerlyReadResponse = (boolean) context.getData(HttpUtils.AZURE_EAGERLY_READ_RESPONSE).orElse(false);
boolean ignoreResponseBody = (boolean) context.getData(HttpUtils.AZURE_IGNORE_RESPONSE_BODY).orElse(false);
boolean headersEagerlyConverted
= (boolean) context.getData(HttpUtils.AZURE_EAGERLY_CONVERT_HEADERS).orElse(false);
Long responseTimeout = context.getData(HttpUtils.AZURE_RESPONSE_TIMEOUT)
.filter(timeoutDuration -> timeoutDuration instanceof Duration)
.map(timeoutDuration -> ((Duration) timeoutDuration).toMillis())
.orElse(null);
Expand Down
Loading