Skip to content
Snippets Groups Projects
Commit 715c8893 authored by Alok Joshi's avatar Alok Joshi
Browse files

remove mutex lock

parent cfef2bc7
No related branches found
No related tags found
1 merge request!74use createItem instead of upsertItem for create api
Pipeline #14266 failed
......@@ -32,14 +32,11 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
@Repository
public class LegalTagRepositoryImpl implements ILegalTagRepository {
private ReentrantLock mutex = new ReentrantLock();
@Autowired
private CosmosStore cosmosStore;
......@@ -59,16 +56,11 @@ public class LegalTagRepositoryImpl implements ILegalTagRepository {
String strId = String.valueOf(id);
LegalTagDoc legalTagDoc = new LegalTagDoc(strId, legalTag);
try {
mutex.lock();
Optional<LegalTagDoc> existingDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class);
if (existingDoc.isPresent()) {
throw AppException.legalTagAlreadyExistsError(legalTag.getName());
}
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, legalTagDoc);
} finally {
mutex.unlock();
Optional<LegalTagDoc> existingDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class);
if (existingDoc.isPresent()) {
throw AppException.legalTagAlreadyExistsError(legalTag.getName());
}
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, legalTagDoc);
return id;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment