Use custom async thread execution pool
The new pool has a limited thread size (cpu core count - 1) and should avoid bot attacks to crash the machine.
This commit is contained in:
@@ -3,6 +3,7 @@ package fr.xephi.authme.initialization;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ReflectionTestUtils;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginLogger;
|
||||
@@ -49,6 +50,8 @@ public class TaskCloserTest {
|
||||
private BukkitScheduler bukkitScheduler;
|
||||
@Mock
|
||||
private DataSource dataSource;
|
||||
@Mock
|
||||
private BukkitService bukkitService;
|
||||
|
||||
@Before
|
||||
public void initAuthMe() {
|
||||
@@ -56,7 +59,7 @@ public class TaskCloserTest {
|
||||
given(server.getScheduler()).willReturn(bukkitScheduler);
|
||||
ReflectionTestUtils.setField(JavaPlugin.class, authMe, "server", server);
|
||||
ReflectionTestUtils.setField(JavaPlugin.class, authMe, "logger", logger);
|
||||
taskCloser = spy(new TaskCloser(authMe, dataSource));
|
||||
taskCloser = spy(new TaskCloser(authMe, dataSource, bukkitService));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,7 +123,7 @@ public class TaskCloserTest {
|
||||
/** Test implementation for {@link #shouldStopForInterruptedThread()}. */
|
||||
private void shouldStopForInterruptedThread0() throws InterruptedException {
|
||||
// given
|
||||
taskCloser = spy(new TaskCloser(authMe, null));
|
||||
taskCloser = spy(new TaskCloser(authMe, null, bukkitService));
|
||||
// First two times do nothing, third time throw exception when we sleep
|
||||
doNothing().doNothing().doThrow(InterruptedException.class).when(taskCloser).sleep();
|
||||
mockActiveWorkers();
|
||||
|
||||
Reference in New Issue
Block a user