Fix entityManager.merge for ds and sm (#2602)

Signed-off-by: Avgustin Marinov <Avgustin.Marinov@bosch.com>
This commit is contained in:
Avgustin Marinov
2025-08-08 16:39:18 +03:00
committed by GitHub
parent bff77ac224
commit 861483f0d6
4 changed files with 12 additions and 7 deletions

View File

@@ -1982,10 +1982,9 @@ class MgmtRolloutResourceTest extends AbstractManagementApiIntegrationTest {
.andExpect(jsonPath("$._links.start.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/start"))))
.andExpect(jsonPath("$._links.pause.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/pause"))))
.andExpect(jsonPath("$.dynamic", equalTo(isDynamic)))
.andExpect(
jsonPath("$._links.resume.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/resume"))))
.andExpect(jsonPath("$._links.groups.href",
allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))));
.andExpect(jsonPath("$._links.resume.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), endsWith("/resume"))))
.andExpect(jsonPath(
"$._links.groups.href", allOf(startsWith(HREF_ROLLOUT_PREFIX), containsString("/deploygroups"))));
}
private Rollout createRollout(final String name, final int amountGroups, final long distributionSetId,

View File

@@ -728,7 +728,13 @@ public class JpaDeploymentManagement extends JpaActionManagement implements Depl
// implicitly lock, for some reason no update happen if lock in same transaction
distributionSet = DeploymentHelper.runInNewTransaction(
txManager, "lockDistributionSet-" + dsId,
status -> distributionSetManagement.lock(dsValidAndComplete));
status -> {
if (entityManager.contains(dsValidAndComplete)) {
return distributionSetManagement.lock(dsValidAndComplete);
} else {
return distributionSetManagement.lock(entityManager.merge(dsValidAndComplete));
}
});
} else {
distributionSet = dsValidAndComplete;
}

View File

@@ -430,7 +430,7 @@ public class JpaDistributionSetManagement
private JpaDistributionSet toJpaDistributionSet(final DistributionSet distributionSet) {
if (distributionSet instanceof JpaDistributionSet jpaDistributionSet) {
return entityManager.merge(jpaDistributionSet); // if from
return jpaDistributionSet;
} else {
return getById(distributionSet.getId());
}

View File

@@ -211,7 +211,7 @@ public class JpaSoftwareModuleManagement
private JpaSoftwareModule toJpaSoftwareModule(final SoftwareModule softwareModule) {
if (softwareModule instanceof JpaSoftwareModule jpaSoftwareModule) {
return entityManager.merge(jpaSoftwareModule); // if from
return jpaSoftwareModule;
} else {
return getById(softwareModule.getId());
}