Skip to content

Commit

Permalink
Fix code to avoid potential NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
RustyHMCTS committed Jan 23, 2024
1 parent 6154958 commit 3304097
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import uk.gov.hmcts.opal.dto.AccountSearchDto;
import uk.gov.hmcts.opal.dto.ToJsonString;

import java.util.Objects;
import java.util.Optional;

@Data
Expand Down Expand Up @@ -61,7 +62,10 @@ public static DefendantAccountSearchCriteria fromAccountSearchDto(AccountSearchD
.surname(dto.getSurname())
.forenames(dto.getForename())
.initials(dto.getInitials())
.birthDate(Optional.ofNullable(dto.getDateOfBirth()).map(d -> d.toLocalDate().toString()).orElse(null))
.birthDate(Optional.ofNullable(dto.getDateOfBirth())
.map(d -> d.toLocalDate())
.map(Objects::toString)
.orElse(null))
.addressLine1(dto.getAddressLineOne())
.nationalInsuranceNumber(dto.getNiNumber())
.prosecutorCaseReference(dto.getPcr())
Expand Down

0 comments on commit 3304097

Please sign in to comment.