Skip to content

Commit

Permalink
GCI-142: Check bad code practices through Sonar and fix those issues. (
Browse files Browse the repository at this point in the history
…openmrs#3071)

Fixed some memory leaks.
  • Loading branch information
prathamesh-mutkure authored and dkayiwa committed Dec 26, 2019
1 parent 3bf1768 commit 75b8b35
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions api/src/main/java/org/openmrs/Condition.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@ public Condition(CodedOrFreeText condition, ConditionClinicalStatus clinicalStat
this.verificationStatus = verificationStatus;
this.previousVersion = previousVersion;
this.additionalDetail = additionalDetail;
this.onsetDate = onsetDate;
this.endDate = endDate;
this.onsetDate = onsetDate != null ? new Date(onsetDate.getTime()) : null;
this.endDate = endDate != null ? new Date(endDate.getTime()) : null;
this.patient = patient;
}

Expand Down Expand Up @@ -246,7 +246,7 @@ public void setAdditionalDetail(String additionalDetail) {
* set
*/
public Date getOnsetDate() {
return onsetDate;
return onsetDate != null ? (Date) onsetDate.clone() : null;
}

/**
Expand All @@ -255,7 +255,7 @@ public Date getOnsetDate() {
* @param onsetDate the onset date of the condition to be set
*/
public void setOnsetDate(Date onsetDate) {
this.onsetDate = onsetDate;
this.onsetDate = onsetDate != null ? new Date(onsetDate.getTime()) : null;
}

/**
Expand All @@ -264,7 +264,7 @@ public void setOnsetDate(Date onsetDate) {
* @return endDate - a date object that shows the end date of the condition
*/
public Date getEndDate() {
return endDate;
return endDate != null ? (Date) endDate.clone() : null;
}

/**
Expand All @@ -273,7 +273,7 @@ public Date getEndDate() {
* @param endDate the end date to be set for the condition
*/
public void setEndDate(Date endDate) {
this.endDate = endDate;
this.endDate = endDate != null ? new Date(endDate.getTime()) : null;
}

/**
Expand Down

0 comments on commit 75b8b35

Please sign in to comment.