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 NPE when accessing DAO > BSQ SUPPLY #6323

Merged
merged 2 commits into from
Aug 17, 2022
Merged
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 @@ -38,6 +38,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -302,40 +303,40 @@ protected CompletableFuture<Boolean> applyData() {
}


CompletableFuture<Boolean> task7Done = new CompletableFuture<>();
allFutures.add(task7Done);
CompletableFuture<Boolean> task15Done = new CompletableFuture<>();
allFutures.add(task15Done);
model.getCompensationAmount()
.whenComplete((data, t) ->
mapToUserThread(() -> {
compensationAmountProperty.set(data);
task7Done.complete(true);
Optional.ofNullable(data).ifPresent(compensationAmountProperty::set);
task15Done.complete(true);
}));

CompletableFuture<Boolean> task8Done = new CompletableFuture<>();
allFutures.add(task8Done);
CompletableFuture<Boolean> task16Done = new CompletableFuture<>();
allFutures.add(task16Done);
model.getReimbursementAmount()
.whenComplete((data, t) ->
mapToUserThread(() -> {
reimbursementAmountProperty.set(data);
task8Done.complete(true);
Optional.ofNullable(data).ifPresent(reimbursementAmountProperty::set);
task16Done.complete(true);
}));

CompletableFuture<Boolean> task9Done = new CompletableFuture<>();
allFutures.add(task9Done);
CompletableFuture<Boolean> task17Done = new CompletableFuture<>();
allFutures.add(task17Done);
model.getBsqTradeFeeAmount()
.whenComplete((data, t) ->
mapToUserThread(() -> {
bsqTradeFeeAmountProperty.set(data);
task9Done.complete(true);
Optional.ofNullable(data).ifPresent(bsqTradeFeeAmountProperty::set);
task17Done.complete(true);
}));

CompletableFuture<Boolean> task10Done = new CompletableFuture<>();
allFutures.add(task10Done);
CompletableFuture<Boolean> task18Done = new CompletableFuture<>();
allFutures.add(task18Done);
model.getProofOfBurnAmount()
.whenComplete((data, t) ->
mapToUserThread(() -> {
proofOfBurnAmountProperty.set(data);
task10Done.complete(true);
Optional.ofNullable(data).ifPresent(proofOfBurnAmountProperty::set);
task18Done.complete(true);
}));

return CompletableFutureUtils.allOf(allFutures).thenApply(e -> true);
Expand All @@ -345,7 +346,7 @@ private void applyTotalSupply(CompletableFuture<Boolean> completeFuture) {
model.getTotalSupplyChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesTotalSupply.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesTotalSupply.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -354,7 +355,7 @@ private void applySupplyChange(CompletableFuture<Boolean> completeFuture) {
model.getSupplyChangeChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesSupplyChange.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesSupplyChange.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -363,7 +364,7 @@ private void applyTotalTradeFees(CompletableFuture<Boolean> completeFuture) {
model.getTotalTradeFeesChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesTotalTradeFees.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesTotalTradeFees.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -372,7 +373,7 @@ private void applyProofOfBurnFromBtcFees(CompletableFuture<Boolean> completeFutu
model.getProofOfBurnFromBtcFeesChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesProofOfBurnFromBtcFees.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesProofOfBurnFromBtcFees.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -381,7 +382,7 @@ private void applyProofOfBurnFromArbitration(CompletableFuture<Boolean> complete
model.getProofOfBurnFromArbitrationChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesProofOfBurnFromArbitration.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesProofOfBurnFromArbitration.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -390,7 +391,7 @@ private void applyArbitrationDiff(CompletableFuture<Boolean> completeFuture) {
model.getArbitrationDiffByInterval()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesArbitrationDiff.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesArbitrationDiff.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -399,7 +400,7 @@ private void applyTotalIssued(CompletableFuture<Boolean> completeFuture) {
model.getTotalIssuedChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesTotalIssued.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesTotalIssued.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -408,7 +409,7 @@ private void applyCompensation(CompletableFuture<Boolean> completeFuture) {
model.getCompensationChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesCompensation.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesCompensation.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -417,7 +418,7 @@ private void applyReimbursement(CompletableFuture<Boolean> completeFuture) {
model.getReimbursementChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesReimbursement.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesReimbursement.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -426,7 +427,7 @@ private void applyTotalBurned(CompletableFuture<Boolean> completeFuture) {
model.getTotalBurnedChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesTotalBurned.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesTotalBurned.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -435,7 +436,7 @@ private void applyBsqTradeFee(CompletableFuture<Boolean> completeFuture) {
model.getBsqTradeFeeChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesBsqTradeFee.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesBsqTradeFee.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -444,7 +445,7 @@ private void applyProofOfBurn(CompletableFuture<Boolean> completeFuture) {
model.getProofOfBurnChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesProofOfBurn.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesProofOfBurn.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -453,7 +454,7 @@ private void applyReimbursementAfterTagging(CompletableFuture<Boolean> completeF
model.getReimbursementAfterTaggingChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesReimbursementAfterTagging.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesReimbursementAfterTagging.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand All @@ -462,7 +463,7 @@ private void applyBsqTradeFeeAfterTagging(CompletableFuture<Boolean> completeFut
model.getBsqTradeFeeAfterTaggingChartData()
.whenComplete((data, t) ->
mapToUserThread(() -> {
seriesBsqTradeFeeAfterTagging.getData().setAll(data);
Optional.ofNullable(data).ifPresent(seriesBsqTradeFeeAfterTagging.getData()::setAll);
completeFuture.complete(true);
}));
}
Expand Down