Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

updated auditdetails logic #974

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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 @@ -199,8 +199,13 @@ private List<String> getIdList(RequestInfo requestInfo, String tenantId, String
* @param waterConnectionRequest WaterConnectionRequest Object
*/
public void enrichUpdateWaterConnection(WaterConnectionRequest waterConnectionRequest) {
AuditDetails currentAuditDetails = waterConnectionRequest.getWaterConnection().getAuditDetails();
AuditDetails auditDetails = waterServicesUtil
.getAuditDetails(waterConnectionRequest.getRequestInfo().getUserInfo().getUuid(), false);

auditDetails.setCreatedBy(currentAuditDetails.getCreatedBy());
auditDetails.setCreatedTime(currentAuditDetails.getCreatedTime());

Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Potential NullPointerException when accessing currentAuditDetails

Accessing currentAuditDetails.getCreatedBy() and currentAuditDetails.getCreatedTime() without checking if currentAuditDetails is null may lead to a NullPointerException. Consider adding a null check before accessing these methods.

Apply this diff to add a null check:

+        if (currentAuditDetails != null) {
           auditDetails.setCreatedBy(currentAuditDetails.getCreatedBy());
           auditDetails.setCreatedTime(currentAuditDetails.getCreatedTime());
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
AuditDetails currentAuditDetails = waterConnectionRequest.getWaterConnection().getAuditDetails();
AuditDetails auditDetails = waterServicesUtil
.getAuditDetails(waterConnectionRequest.getRequestInfo().getUserInfo().getUuid(), false);
auditDetails.setCreatedBy(currentAuditDetails.getCreatedBy());
auditDetails.setCreatedTime(currentAuditDetails.getCreatedTime());
AuditDetails currentAuditDetails = waterConnectionRequest.getWaterConnection().getAuditDetails();
AuditDetails auditDetails = waterServicesUtil
.getAuditDetails(waterConnectionRequest.getRequestInfo().getUserInfo().getUuid(), false);
if (currentAuditDetails != null) {
auditDetails.setCreatedBy(currentAuditDetails.getCreatedBy());
auditDetails.setCreatedTime(currentAuditDetails.getCreatedTime());
}

waterConnectionRequest.getWaterConnection().setAuditDetails(auditDetails);
WaterConnection connection = waterConnectionRequest.getWaterConnection();
if (!CollectionUtils.isEmpty(connection.getDocuments())) {
Expand Down