gmunozfe commented on code in PR #1990:
URL:
https://github.com/apache/incubator-kie-kogito-apps/pull/1990#discussion_r1494297459
##########
data-index/data-index-storage/data-index-storage-jpa-common/src/main/java/org/kie/kogito/index/jpa/storage/AbstractStorage.java:
##########
@@ -54,19 +51,7 @@ protected AbstractStorage(PanacheRepositoryBase<E, K>
repository, Class<V> model
@Override
@Transactional
public V put(K key, V value) {
- //Pessimistic lock is used to lock the row to handle concurrency with
an exiting registry
- E persistedEntity = repository.findById(key,
LockModeType.PESSIMISTIC_WRITE);
- E newEntity = mapToEntity.apply(value);
- if (persistedEntity != null) {
- repository.getEntityManager().merge(newEntity);
- } else {
- try {
- //to handle concurrency in case of a new registry persist
flush and throw an exception to allow retry on the caller side
- repository.persistAndFlush(newEntity);
- } catch (PersistenceException e) {
- throw new ConcurrentModificationException(e);
- }
- }
+ repository.getEntityManager().merge(mapToEntity.apply(value));
Review Comment:
couldn't `mapToEntity.apply(value)` be null?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]