Archiviert
13
0

Prevent ProtocolLib from spamming the console too.

Dieser Commit ist enthalten in:
Kristian S. Stangeland 2012-12-12 18:34:02 +01:00
Ursprung 15961f6cce
Commit 4440e6fcaa

Datei anzeigen

@ -44,7 +44,8 @@ public class DetailedErrorReporter implements ErrorReporter {
protected String prefix; protected String prefix;
protected String supportURL; protected String supportURL;
protected int errorCount; protected AtomicInteger internalErrorCount = new AtomicInteger();
protected int maxErrorCount; protected int maxErrorCount;
protected Logger logger; protected Logger logger;
@ -185,13 +186,19 @@ public class DetailedErrorReporter implements ErrorReporter {
public void reportDetailed(Object sender, String message, Throwable error, Object... parameters) { public void reportDetailed(Object sender, String message, Throwable error, Object... parameters) {
final Plugin plugin = pluginReference.get(); final Plugin plugin = pluginReference.get();
final int errorCount = internalErrorCount.incrementAndGet();
// Do not overtly spam the server! // Do not overtly spam the server!
if (++errorCount > maxErrorCount) { if (errorCount > getMaxErrorCount()) {
String maxReached = String.format("Reached maxmimum error count. Cannot pass error %s from %s.", error, sender); // Only allow the error count at rare occations
logger.severe(maxReached); if (isPowerOfTwo(errorCount)) {
// Permit it - but print the number of exceptions first
reportWarning(this, "Internal exception count: " + errorCount + "!");
} else {
// NEVER SPAM THE CONSOLE
return; return;
} }
}
StringWriter text = new StringWriter(); StringWriter text = new StringWriter();
PrintWriter writer = new PrintWriter(text); PrintWriter writer = new PrintWriter(text);
@ -297,11 +304,11 @@ public class DetailedErrorReporter implements ErrorReporter {
} }
public int getErrorCount() { public int getErrorCount() {
return errorCount; return internalErrorCount.get();
} }
public void setErrorCount(int errorCount) { public void setErrorCount(int errorCount) {
this.errorCount = errorCount; internalErrorCount.set(errorCount);
} }
public int getMaxErrorCount() { public int getMaxErrorCount() {