PC-951 Fix handler message task not being cancelled when closing report
This commit is contained in:
parent
5e5cb3284a
commit
a5e5be4329
@ -37,6 +37,7 @@ public class ReportHandlerTask extends BukkitRunnable
|
||||
public void start(JavaPlugin plugin)
|
||||
{
|
||||
runTaskTimer(plugin, 1L, 20L * 10);
|
||||
_report.cancelHandlerTask(); // cancel in case other task running
|
||||
_report.setHandlerTask(this);
|
||||
}
|
||||
|
||||
|
@ -239,13 +239,12 @@ public class ReportManager
|
||||
}
|
||||
|
||||
report.setReportResult(reportResult);
|
||||
report.cancelHandlerTask();
|
||||
|
||||
CompletableFuture<Long> saveCompletableFuture = saveReport(report);
|
||||
|
||||
saveCompletableFuture.thenAccept(reportId ->
|
||||
{
|
||||
_reportRepository.clearCache(reportId);
|
||||
|
||||
if (reportCloser != null)
|
||||
{
|
||||
if (reportResult.getType() == ReportResultType.ABUSIVE)
|
||||
@ -296,6 +295,8 @@ public class ReportManager
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_reportRepository.clearCache(reportId);
|
||||
}).exceptionally(throwable -> {
|
||||
_plugin.getLogger().log(Level.SEVERE, "Post-report save failed.", throwable);
|
||||
return null;
|
||||
@ -632,14 +633,7 @@ public class ReportManager
|
||||
if (reportOptional.isPresent())
|
||||
{
|
||||
Report report = reportOptional.get();
|
||||
Optional<ReportHandlerTask> handlerTaskOptional = report.getHandlerTask();
|
||||
|
||||
if (handlerTaskOptional.isPresent())
|
||||
{
|
||||
ReportHandlerTask handlerTask = handlerTaskOptional.get();
|
||||
handlerTask.cancel();
|
||||
report.setHandlerTask(null);
|
||||
}
|
||||
report.cancelHandlerTask();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -131,4 +131,13 @@ public class Report
|
||||
{
|
||||
_handlerTask = handlerTask;
|
||||
}
|
||||
|
||||
public void cancelHandlerTask()
|
||||
{
|
||||
if (_handlerTask != null)
|
||||
{
|
||||
_handlerTask.cancel();
|
||||
_handlerTask = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user