Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,13 @@ private void deleteProjectWithDependants(Project project) {
.filter(issueType -> !defaultIssueTypeIds.contains(issueType.getId()))
.collect(Collectors.toSet());

projectContentRemover.remove(project);
projectRepository.delete(project);
issueTypeRepository.deleteAll(issueTypesToRemove);
logIndexer.deleteIndex(project.getId());
analyzerServiceClient.removeSuggest(project.getId());
logRepository.deleteByProjectId(project.getId());
attachmentBinaryDataService.deleteAllByProjectId(project.getId());
projectContentRemover.remove(project);
projectRepository.delete(project);
Comment on lines 241 to +246

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

External cleanup runs before the irreversible project delete path.

On Lines 241-246, index/suggestion cleanup happens before projectContentRemover.remove(project) and projectRepository.delete(project). If a later DB delete step fails, the project can remain while external search/analyzer data is already removed.

Suggested ordering change
-    logIndexer.deleteIndex(project.getId());
-    analyzerServiceClient.removeSuggest(project.getId());
     logRepository.deleteByProjectId(project.getId());
     attachmentBinaryDataService.deleteAllByProjectId(project.getId());
     projectContentRemover.remove(project);
     projectRepository.delete(project);
+    logIndexer.deleteIndex(project.getId());
+    analyzerServiceClient.removeSuggest(project.getId());
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@src/main/java/com/epam/reportportal/base/core/project/impl/OrganizationProjectHandlerImpl.java`
around lines 241 - 246, The cleanup of external systems (logIndexer.deleteIndex,
analyzerServiceClient.removeSuggest, logRepository.deleteByProjectId,
attachmentBinaryDataService.deleteAllByProjectId) is executed before the
irreversible DB removals (projectContentRemover.remove and
projectRepository.delete), which can leave the DB state inconsistent if a later
DB delete fails; move the external cleanup calls so they run after
projectContentRemover.remove(project) and projectRepository.delete(project) (and
consider keeping them in their existing order), and optionally guard these
external calls with try/catch/logging to handle failures without affecting the
completed DB delete.


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.epam.reportportal.base.infrastructure.persistence.commons.JsonbUserType;
import java.io.Serializable;
import java.util.Map;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
Expand All @@ -43,4 +44,21 @@ public class SenderCaseOptions extends JsonbUserType<SenderCaseOptions> implemen
public Class<SenderCaseOptions> returnedClass() {
return SenderCaseOptions.class;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
SenderCaseOptions that = (SenderCaseOptions) o;
return Objects.equals(options, that.options);
}

@Override
public int hashCode() {
return Objects.hash(options);
}
}
Loading