Skip to content

Commit cbfec55

Browse files
committed
make sure to set values asynchronously
1 parent 3915292 commit cbfec55

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

agent/update/src/main/java/me/hsgamer/topper/agent/update/UpdateAgent.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ public void run() {
3737
break;
3838
}
3939
DataEntry<K, V> entry = holder.getOrCreateEntry(k);
40-
updateFunction.apply(k).whenComplete((optional, throwable) -> {
41-
if (throwable != null) {
42-
logger.log(Level.WARNING, "An error occurred while updating the entry: " + k, throwable);
43-
} else {
44-
optional.ifPresent(entry::setValue);
45-
}
46-
updateQueue.add(k);
47-
});
40+
updateFunction.apply(k)
41+
.thenAcceptAsync(optional -> optional.ifPresent(entry::setValue))
42+
.whenComplete((v, throwable) -> {
43+
if (throwable != null) {
44+
logger.log(Level.WARNING, "An error occurred while updating the entry: " + k, throwable);
45+
}
46+
updateQueue.add(k);
47+
});
4848
}
4949
}
5050

0 commit comments

Comments
 (0)