Skip to content

Commit

Permalink
bug: 1082 add retry in case of a duplicate key error
Browse files Browse the repository at this point in the history
  • Loading branch information
ds-lcapellino committed Jul 8, 2024
1 parent 2231e06 commit dd4c29c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.eclipse.tractusx.traceability.assets.domain.base.model.ImportNote;
import org.eclipse.tractusx.traceability.assets.domain.base.model.ImportState;
import org.eclipse.tractusx.traceability.assets.domain.base.model.Owner;
import org.eclipse.tractusx.traceability.assets.infrastructure.asbuilt.model.AssetAsBuiltEntity;
import org.eclipse.tractusx.traceability.assets.infrastructure.asplanned.model.AssetAsPlannedEntity;
import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.AssetCallbackRepository;
import org.eclipse.tractusx.traceability.assets.infrastructure.base.model.AssetBaseEntity;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.eclipse.tractusx.traceability.assets.infrastructure.base.irs.model.response.factory.IrsResponseAssetMapper;
import org.eclipse.tractusx.traceability.common.properties.TraceabilityProperties;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.stereotype.Service;

import java.util.List;
Expand Down Expand Up @@ -108,7 +109,12 @@ public void handleJobFinishedCallback(String jobId, String state) {
}

void saveOrUpdateAssets(AssetCallbackRepository repository, AssetBase asset) {
repository.save(asset);
try {
repository.save(asset);
} catch (DataIntegrityViolationException ex) {
//retry save in case of ERROR: duplicate key value violates unique constraint "asset_pkey"
repository.save(asset);
}
}


Expand Down

0 comments on commit dd4c29c

Please sign in to comment.