Skip to content

Commit 0d1c83b

Browse files
authored
Remove potential NPE during first worker replicate request (#652)
1 parent d79c7ba commit 0d1c83b

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ All notable changes to this project will be documented in this file.
3131
- Remove duplicated MongoDB read on `ReplicatesList` during replicate status update. (#647)
3232
- Use less MongoDB calls when updating a task to a final status. (#649)
3333
- Save contribution and result updload replicate data when `CONTRIBUTE_AND_FINALIZE_DONE`. (#651)
34+
- Fix potential `NullPointerException` during first worker replicate request. (#652)
3435

3536
### Dependency Upgrades
3637

src/main/java/com/iexec/core/worker/WorkerService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ public boolean isAllowedToJoin(String workerAddress) {
121121
}
122122

123123
public boolean isWorkerAllowedToAskReplicate(String walletAddress) {
124-
Date lastReplicateDemandDate = workerStatsMap.get(walletAddress).getLastReplicateDemandDate();
124+
Date lastReplicateDemandDate = workerStatsMap.computeIfAbsent(walletAddress, WorkerStats::new)
125+
.getLastReplicateDemandDate();
125126
if (lastReplicateDemandDate == null) {
126127
return true;
127128
}

0 commit comments

Comments
 (0)