Commit 854d570b authored by Mayank Saggar [Microsoft]'s avatar Mayank Saggar [Microsoft]
Browse files

Replace Item Now returns a Optional container instance of the updated Item

parent 99ebbd63
Pipeline #20570 failed with stages
in 55 seconds
......@@ -186,8 +186,9 @@ public class CosmosStore {
* @param partitionKey Partition key of item
* @param item Data object to store
* @param <T> Type of item
* @return The replaced item
*/
public <T> void replaceItem(
public <T> Optional<T> replaceItem(
final String dataPartitionId,
final String cosmosDBName,
final String collection,
......@@ -198,7 +199,8 @@ public class CosmosStore {
CosmosContainer cosmosContainer = getCosmosContainer(dataPartitionId, cosmosDBName, collection);
PartitionKey key = new PartitionKey(partitionKey);
CosmosItemRequestOptions options = new CosmosItemRequestOptions();
cosmosContainer.replaceItem(item, id, key, options);
T updateItem = cosmosContainer.replaceItem(item, id, key, options).getItem();
return Optional.ofNullable((T) updateItem);
} catch (NotFoundException e) {
String errorMessage = "Item was unexpectedly not found";
LOGGER.warn(errorMessage, e);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment