mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-27 19:47:49 +01:00
Analysis DB Closed Exception on reload no longer logged.
This commit is contained in:
parent
9e91ee61f8
commit
ec1ea81f93
@ -7,6 +7,7 @@ package com.djrapitops.plan.system.info.request;
|
|||||||
import com.djrapitops.plan.api.exceptions.connection.BadRequestException;
|
import com.djrapitops.plan.api.exceptions.connection.BadRequestException;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.InternalErrorException;
|
import com.djrapitops.plan.api.exceptions.connection.InternalErrorException;
|
||||||
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
import com.djrapitops.plan.api.exceptions.connection.WebException;
|
||||||
|
import com.djrapitops.plan.api.exceptions.database.DBException;
|
||||||
import com.djrapitops.plan.data.calculation.AnalysisData;
|
import com.djrapitops.plan.data.calculation.AnalysisData;
|
||||||
import com.djrapitops.plan.system.cache.DataCache;
|
import com.djrapitops.plan.system.cache.DataCache;
|
||||||
import com.djrapitops.plan.system.database.databases.Database;
|
import com.djrapitops.plan.system.database.databases.Database;
|
||||||
@ -83,8 +84,13 @@ public class GenerateAnalysisPageRequest extends InfoRequestWithVariables implem
|
|||||||
|
|
||||||
AnalysisData analysisData = Analysis.runAnalysisFor(serverUUID, db, dataCache);
|
AnalysisData analysisData = Analysis.runAnalysisFor(serverUUID, db, dataCache);
|
||||||
return new AnalysisPage(analysisData).toHtml();
|
return new AnalysisPage(analysisData).toHtml();
|
||||||
|
} catch (DBException e) {
|
||||||
|
if (!e.getCause().getMessage().contains("Connection is closed")) {
|
||||||
|
Log.toLog(this.getClass(), e);
|
||||||
|
}
|
||||||
|
throw new InternalErrorException("Analysis failed due to exception", e);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(Analysis.class, e);
|
Log.toLog(this.getClass(), e);
|
||||||
throw new InternalErrorException("Analysis failed due to exception", e);
|
throw new InternalErrorException("Analysis failed due to exception", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,11 @@ public class ProcessingQueue extends Queue<Processor> implements SubSystem {
|
|||||||
List<Processor> processors = stopAndReturnLeftovers();
|
List<Processor> processors = stopAndReturnLeftovers();
|
||||||
Log.info("Processing unprocessed processors. (" + processors.size() + ")");
|
Log.info("Processing unprocessed processors. (" + processors.size() + ")");
|
||||||
for (Processor processor : processors) {
|
for (Processor processor : processors) {
|
||||||
processor.process();
|
try {
|
||||||
|
processor.process();
|
||||||
|
} catch (Exception e) {
|
||||||
|
Log.toLog(this.getClass(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,11 @@ import com.djrapitops.plan.Plan;
|
|||||||
import com.djrapitops.plugin.StaticHolder;
|
import com.djrapitops.plugin.StaticHolder;
|
||||||
import com.djrapitops.plugin.task.RunnableFactory;
|
import com.djrapitops.plugin.task.RunnableFactory;
|
||||||
import com.djrapitops.plugin.task.ThreadRunnable;
|
import com.djrapitops.plugin.task.ThreadRunnable;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.plugin.InvalidDescriptionException;
|
import org.bukkit.plugin.InvalidDescriptionException;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
import org.bukkit.scheduler.BukkitScheduler;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
import org.mockito.junit.MockitoJUnitRunner;
|
||||||
import utilities.Teardown;
|
import utilities.Teardown;
|
||||||
@ -22,8 +24,7 @@ import java.io.File;
|
|||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
|
|
||||||
import static org.mockito.Mockito.doCallRealMethod;
|
import static org.mockito.Mockito.*;
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mocking Utility for Bukkit version of Plan.
|
* Mocking Utility for Bukkit version of Plan.
|
||||||
@ -54,6 +55,7 @@ public class BukkitMockUtil extends MockUtil {
|
|||||||
|
|
||||||
doCallRealMethod().when(planMock).getVersion();
|
doCallRealMethod().when(planMock).getVersion();
|
||||||
doCallRealMethod().when(planMock).getColorScheme();
|
doCallRealMethod().when(planMock).getColorScheme();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,7 +67,7 @@ public class BukkitMockUtil extends MockUtil {
|
|||||||
public BukkitMockUtil withLogging() {
|
public BukkitMockUtil withLogging() {
|
||||||
doCallRealMethod().when(planMock).log(Mockito.anyString(), Mockito.anyString());
|
doCallRealMethod().when(planMock).log(Mockito.anyString(), Mockito.anyString());
|
||||||
TestLogger testLogger = new TestLogger();
|
TestLogger testLogger = new TestLogger();
|
||||||
when(planMock.getLogger()).thenReturn(testLogger);
|
doReturn(testLogger).when(planMock).getLogger();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +100,11 @@ public class BukkitMockUtil extends MockUtil {
|
|||||||
FakeConsoleCmdSender sender = new FakeConsoleCmdSender();
|
FakeConsoleCmdSender sender = new FakeConsoleCmdSender();
|
||||||
when(serverMock.getConsoleSender()).thenReturn(sender);
|
when(serverMock.getConsoleSender()).thenReturn(sender);
|
||||||
|
|
||||||
|
BukkitScheduler bukkitScheduler = Mockito.mock(BukkitScheduler.class);
|
||||||
|
doReturn(bukkitScheduler).when(serverMock).getScheduler();
|
||||||
|
|
||||||
|
Bukkit.setServer(serverMock);
|
||||||
|
|
||||||
when(planMock.getServer()).thenReturn(serverMock);
|
when(planMock.getServer()).thenReturn(serverMock);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import com.djrapitops.plan.PlanPlugin;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
|
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.doReturn;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract MockUtil for methods that can be used for both Bungee and Bukkit.
|
* Abstract MockUtil for methods that can be used for both Bungee and Bukkit.
|
||||||
@ -30,7 +30,7 @@ abstract class MockUtil {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
File file = getFile("/" + fileName);
|
File file = getFile("/" + fileName);
|
||||||
when(planMock.getResource(fileName)).thenReturn(new FileInputStream(file));
|
doReturn(new FileInputStream(file)).when(planMock).getResource(fileName);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
System.out.println("File is missing! " + fileName);
|
System.out.println("File is missing! " + fileName);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user