Skip to content

Commit 9f18955

Browse files
committed
make async metrics actually async
1 parent c4a0588 commit 9f18955

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/main/java/de/sldk/mc/metrics/Metric.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,29 @@ public CompletableFuture<Void> collect() {
3333
}
3434

3535
if (isAsyncCapable()) {
36-
CompletableFuture.runAsync(() -> {
36+
return CompletableFuture.runAsync(() -> {
3737
try {
3838
doCollect();
3939
} catch (Exception e) {
4040
logException(e);
4141
}
4242
});
43-
}
44-
45-
CompletableFuture<Void> future = new CompletableFuture<>();
43+
} else {
44+
CompletableFuture<Void> future = new CompletableFuture<>();
4645

47-
// don't call .get() - this blocks the ForkJoinPool.commonPool and may deadlock the server in some cases
48-
Bukkit.getScheduler().callSyncMethod(plugin, () -> {
49-
try {
50-
doCollect();
51-
} catch (Exception e) {
52-
logException(e);
53-
}
54-
future.complete(null);
55-
return null;
56-
});
46+
// don't call .get() - this blocks the ForkJoinPool.commonPool and may deadlock the server in some cases
47+
Bukkit.getScheduler().callSyncMethod(plugin, () -> {
48+
try {
49+
doCollect();
50+
} catch (Exception e) {
51+
logException(e);
52+
}
53+
future.complete(null);
54+
return null;
55+
});
5756

58-
return future;
57+
return future;
58+
}
5959
}
6060

6161
protected abstract void doCollect();

0 commit comments

Comments
 (0)