Skip to content
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
2 changes: 1 addition & 1 deletion core/src/main/java/dev/faststats/Metrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Factory {
Factory addMetric(Metric<?> metric) throws IllegalArgumentException;

/**
* Sets the flush callback for this metrics instance.
* Adds a flush callback to this metrics instance.
* <p>
* This callback will be invoked when the metrics have been submitted to, and accepted by, the metrics server.
*
Expand Down
8 changes: 7 additions & 1 deletion core/src/main/java/dev/faststats/SimpleMetrics.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,13 @@ public Factory addMetric(final Metric<?> metric) throws IllegalArgumentException

@Override
public Factory onFlush(final Runnable flush) {
this.flush = flush;
final var runnable = this.flush;
if (runnable == null) {
this.flush = flush;
} else this.flush = () -> {
runnable.run();
flush.run();
};
return this;
}
}
Expand Down
Loading