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

Commit

Permalink
chore: nullchek
Browse files Browse the repository at this point in the history
  • Loading branch information
nemo83 committed Jul 15, 2024
1 parent 6de07f1 commit 0a37578
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.cardanofoundation.job.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
import lombok.experimental.FieldDefaults;
import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Service;

Expand All @@ -16,6 +18,7 @@

@Service
@RequiredArgsConstructor
@Slf4j
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
public class MultiAssetServiceImpl implements MultiAssetService {

Expand All @@ -33,10 +36,17 @@ public class MultiAssetServiceImpl implements MultiAssetService {
*/
@Override
public Map<String, Long> getMapNumberHolderByUnits(List<String> units) {
var numberOfHolders = addressTxAmountRepository.countHoldersByMultiAssetIdInRange(units);
return StreamUtil.toMap(
numberOfHolders,
TokenNumberHoldersProjection::getUnit,
TokenNumberHoldersProjection::getNumberOfHolders);
try {
var numberOfHolders = addressTxAmountRepository.countHoldersByMultiAssetIdInRange(units);
if (numberOfHolders != null) {
log.info("numberOfHolders is not null, size: {}", numberOfHolders.size());
return StreamUtil.toMap(
numberOfHolders,
TokenNumberHoldersProjection::getUnit,
TokenNumberHoldersProjection::getNumberOfHolders);
}
} catch (Exception e) {
return new HashMap<>();
}
}
}

0 comments on commit 0a37578

Please sign in to comment.