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; ...@@ -32,14 +32,11 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Repository @Repository
public class LegalTagRepositoryImpl implements ILegalTagRepository { public class LegalTagRepositoryImpl implements ILegalTagRepository {
private ReentrantLock mutex = new ReentrantLock();
@Autowired @Autowired
private CosmosStore cosmosStore; private CosmosStore cosmosStore;
...@@ -59,16 +56,11 @@ public class LegalTagRepositoryImpl implements ILegalTagRepository { ...@@ -59,16 +56,11 @@ public class LegalTagRepositoryImpl implements ILegalTagRepository {
String strId = String.valueOf(id); String strId = String.valueOf(id);
LegalTagDoc legalTagDoc = new LegalTagDoc(strId, legalTag); LegalTagDoc legalTagDoc = new LegalTagDoc(strId, legalTag);
try { Optional<LegalTagDoc> existingDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class);
mutex.lock(); if (existingDoc.isPresent()) {
Optional<LegalTagDoc> existingDoc = cosmosStore.findItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, strId, strId, LegalTagDoc.class); throw AppException.legalTagAlreadyExistsError(legalTag.getName());
if (existingDoc.isPresent()) {
throw AppException.legalTagAlreadyExistsError(legalTag.getName());
}
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, legalTagDoc);
} finally {
mutex.unlock();
} }
cosmosStore.createItem(headers.getPartitionId(), cosmosDBName, legalTagsContainer, legalTagDoc);
return id; 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