Skip to content

Commit

Permalink
DocumentClientException is now thread-safe (#323)
Browse files Browse the repository at this point in the history
* DocumentClientException is now thread-safe (but offers no consistency guarantees) and we have a test that request/response headers can be enumerated while they're being updated (sans ConcurrentModificationExceptions).

* Bug fix: Adjust for fact that ConcurrentMap does not accept the null values that we sometimes pass.

* Added two new DocumentClientExceptionTest methods and increased the timeout interval on ConsistencyTest2.validateSessionTokenAsync because it times out regularly in local and CI test runs with the old timeout interval.
  • Loading branch information
David-Noble-at-work committed Mar 11, 2020
1 parent 3511f32 commit ca47cad
Show file tree
Hide file tree
Showing 7 changed files with 299 additions and 92 deletions.
8 changes: 7 additions & 1 deletion commons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ SOFTWARE.
<artifactId>guava</artifactId>
<version>${guava.version}</version>
<scope>test</scope>
</dependency>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
<version>${micrometer.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.microsoft.azure.cosmosdb.rx.internal.RxDocumentServiceResponse;
import com.microsoft.azure.cosmosdb.rx.internal.Strings;

import java.net.URI;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
Expand Down Expand Up @@ -179,29 +178,29 @@ public static <T extends Resource> FeedResponse<T> createFeedResponseWithQueryMe
}

public static <E extends DocumentClientException> E setResourceAddress(E e, String resourceAddress) {
e.resourceAddress = resourceAddress;
e.setResourceAddress(resourceAddress);
return e;
}

public static <E extends DocumentClientException> long getLSN(E e) {
return e.lsn;
return e.getLsn();
}

public static <E extends DocumentClientException> String getPartitionKeyRangeId(E e) {
return e.partitionKeyRangeId;
return e.getPartitionKeyRangeId();
}

public static <E extends DocumentClientException> String getResourceAddress(E e) {
return e.resourceAddress;
return e.getResourceAddress();
}

public static <E extends DocumentClientException> E setLSN(E e, long lsn) {
e.lsn = lsn;
e.setLsn(lsn);
return e;
}

public static <E extends DocumentClientException> E setPartitionKeyRangeId(E e, String partitionKeyRangeId) {
e.partitionKeyRangeId = partitionKeyRangeId;
e.setPartitionKeyRangeId(partitionKeyRangeId);
return e;
}

Expand All @@ -218,15 +217,15 @@ public static void setUseMultipleWriteLocations(ConnectionPolicy policy, boolean
}

public static <E extends DocumentClientException> Uri getRequestUri(DocumentClientException documentClientException) {
return documentClientException.requestUri;
return documentClientException.getRequestUri();
}

public static <E extends DocumentClientException> void setRequestHeaders(DocumentClientException documentClientException, Map<String, String> requestHeaders) {
documentClientException.requestHeaders = requestHeaders;
documentClientException.setRequestHeaders(requestHeaders);
}

public static <E extends DocumentClientException> Map<String, String> getRequestHeaders(DocumentClientException documentClientException) {
return documentClientException.requestHeaders;
return documentClientException.getRequestHeaders();
}

public static Map<String, Object> getQueryEngineConfiuration(DatabaseAccount databaseAccount) {
Expand Down
Loading

0 comments on commit ca47cad

Please sign in to comment.