Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: null pointer ex when poolFetchList from koios is empty #102

Merged
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 @@ -16,6 +16,7 @@
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import io.micrometer.common.util.StringUtils;
import rest.koios.client.backend.api.base.exception.ApiException;
Expand Down Expand Up @@ -49,6 +50,10 @@ public CompletableFuture<Boolean> fetchData(List<String> poolIds) {
int currentEpoch = epochService.getCurrentEpoch();
var dataFromKoios = getPoolInfoList(poolIds);

if (CollectionUtils.isEmpty(dataFromKoios)) {
return CompletableFuture.completedFuture(Boolean.TRUE);
}

var poolHashMap =
poolHashRepository.findByViewIn(poolIds).stream()
.collect(Collectors.toMap(PoolHash::getView, Function.identity()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;

import io.micrometer.common.util.StringUtils;
import rest.koios.client.backend.api.base.exception.ApiException;
Expand Down Expand Up @@ -60,6 +61,10 @@ public CompletableFuture<Boolean> fetchData(String poolId) {
var dataFromKoios = getPoolHistoryList(poolId);
var poolHistoryCheckpoint = poolHistoryCheckpointRepository.findByView(poolId);

if (CollectionUtils.isEmpty(dataFromKoios)) {
return CompletableFuture.completedFuture(Boolean.TRUE);
}

Map<Integer, PoolHistory> poolHistoryList =
dataFromKoios.stream()
.filter(poolHistory -> poolHistory.getEpochNo() < currentEpoch)
Expand Down
Loading