Try to debug unreqwuired .changed calls

This commit is contained in:
Magnus Ulf Jørgensen 2018-04-29 17:20:48 +02:00 committed by Olof Larsson
parent 17526c3f5f
commit 84104fa03a
5 changed files with 59 additions and 11 deletions

View File

@ -259,6 +259,14 @@ public class MassiveCore extends MassivePlugin
// Delete Files (at once and additionally after all plugins loaded) // Delete Files (at once and additionally after all plugins loaded)
MassiveCoreTaskDeleteFiles.get().run(); MassiveCoreTaskDeleteFiles.get().run();
Bukkit.getScheduler().scheduleSyncDelayedTask(this, MassiveCoreTaskDeleteFiles.get()); Bukkit.getScheduler().scheduleSyncDelayedTask(this, MassiveCoreTaskDeleteFiles.get());
// Uneccessary call of .changed() for debug
Bukkit.getScheduler().runTaskLater(this, new Runnable() {
@Override
public void run() {
MassiveCoreMConf.get().changed();
}
}, 200L);
} }
@Override @Override

View File

@ -132,6 +132,9 @@ public class MassiveCoreMConf extends Entity<MassiveCoreMConf>
@EditorType(TypeBooleanOn.class) @EditorType(TypeBooleanOn.class)
public boolean warnOnLocalAlter = false; public boolean warnOnLocalAlter = false;
@EditorType(TypeBooleanOn.class)
public boolean advancedLocalPollingDebug = false;
// -------------------------------------------- // // -------------------------------------------- //
// CLEAN // CLEAN

View File

@ -9,7 +9,6 @@ import com.massivecraft.massivecore.comparator.ComparatorNaturalOrder;
import com.massivecraft.massivecore.mixin.MixinModification; import com.massivecraft.massivecore.mixin.MixinModification;
import com.massivecraft.massivecore.store.migrator.MigratorUtil; import com.massivecraft.massivecore.store.migrator.MigratorUtil;
import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.ReflectionUtil;
import com.massivecraft.massivecore.util.Txt; import com.massivecraft.massivecore.util.Txt;
import com.massivecraft.massivecore.xlib.gson.Gson; import com.massivecraft.massivecore.xlib.gson.Gson;
import com.massivecraft.massivecore.xlib.gson.JsonElement; import com.massivecraft.massivecore.xlib.gson.JsonElement;
@ -555,7 +554,13 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
this.removeIdentifiedModificationFixed(id); this.removeIdentifiedModificationFixed(id);
break; break;
} }
E entity = this.getFixed(id);
if (entity != null)
{
entity.setLastStackTraceChanged(null);
}
return modification; return modification;
} }
@ -595,7 +600,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
private void checkActuallyModifiedFixed(String id) private void checkActuallyModifiedFixed(String id)
{ {
if (!ConfServer.localPollingEnabled || !MassiveCoreMConf.get().warnOnLocalAlter) return; if (!MStore.isLocalPollingDebugEnabled()) return;
E entity = this.getFixed(id); E entity = this.getFixed(id);
boolean modified = this.examineHasLocalAlterFixed(id, entity); boolean modified = this.examineHasLocalAlterFixed(id, entity);
@ -607,6 +612,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
String change = Txt.implode(messages, Txt.parse("<silver> | ")); String change = Txt.implode(messages, Txt.parse("<silver> | "));
String message = Txt.parse("<b>[No Modification] %s", change); String message = Txt.parse("<b>[No Modification] %s", change);
this.getPlugin().log(message); this.getPlugin().log(message);
if (entity.getLastStackTraceChanged() != null) this.getPlugin().log(MUtil.getStackTraceString(entity.getLastStackTraceChanged(), true));
} }
protected void logModification(E entity, Modification modification) protected void logModification(E entity, Modification modification)

View File

@ -1,7 +1,12 @@
package com.massivecraft.massivecore.store; package com.massivecraft.massivecore.store;
import com.massivecraft.massivecore.ConfServer;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.xlib.gson.JsonObject; import com.massivecraft.massivecore.xlib.gson.JsonObject;
import java.util.List;
// Self referencing generic. // Self referencing generic.
// http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ206 // http://www.angelikalanger.com/GenericsFAQ/FAQSections/ProgrammingIdioms.html#FAQ206
public class Entity<E extends Entity<E>> extends EntityInternal<E> public class Entity<E extends Entity<E>> extends EntityInternal<E>
@ -31,13 +36,20 @@ public class Entity<E extends Entity<E>> extends EntityInternal<E>
private volatile transient boolean lastDefault = false; private volatile transient boolean lastDefault = false;
public boolean getLastDefault() { return this.lastDefault; } public boolean getLastDefault() { return this.lastDefault; }
public void setLastDefault(boolean lastDefault) { this.lastDefault = lastDefault; } public void setLastDefault(boolean lastDefault) { this.lastDefault = lastDefault; }
private volatile transient List<StackTraceElement> lastStackTraceChanged;
public List<StackTraceElement> getLastStackTraceChanged() { return this.lastStackTraceChanged; }
public void setLastStackTraceChanged(List<StackTraceElement> lastStackTraceChanged) { this.lastStackTraceChanged = lastStackTraceChanged; }
public void clearSyncLogFields() public void clearSyncLogFields()
{ {
this.lastRaw = null; this.lastRaw = null;
this.lastMtime = 0; this.lastMtime = 0;
this.lastDefault = false; this.lastDefault = false;
this.lastStackTraceChanged = null;
} }
// -------------------------------------------- // // -------------------------------------------- //
// ATTACH AND DETACH // ATTACH AND DETACH
@ -62,6 +74,14 @@ public class Entity<E extends Entity<E>> extends EntityInternal<E>
// -------------------------------------------- // // -------------------------------------------- //
// SYNC AND IO ACTIONS // SYNC AND IO ACTIONS
// -------------------------------------------- // // -------------------------------------------- //
@Override
public void changed()
{
super.changed();
if (!MStore.isLocalPollingDebugEnabled() || !MassiveCoreMConf.get().advancedLocalPollingDebug) return;
this.lastStackTraceChanged = MUtil.getStackTrace();
}
public Modification sync() public Modification sync()
{ {

View File

@ -1,6 +1,7 @@
package com.massivecraft.massivecore.store; package com.massivecraft.massivecore.store;
import com.massivecraft.massivecore.ConfServer; import com.massivecraft.massivecore.ConfServer;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.xlib.gson.JsonElement; import com.massivecraft.massivecore.xlib.gson.JsonElement;
import java.net.URI; import java.net.URI;
@ -75,13 +76,13 @@ public class MStore
if (uri == null) return alias; if (uri == null) return alias;
return resolveAlias(uri); return resolveAlias(uri);
} }
public static Db getDb(String alias) public static Db getDb(String alias)
{ {
String uri = resolveAlias(alias); String uri = resolveAlias(alias);
Db db = uri2db.get(uri); Db db = uri2db.get(uri);
if (db != null) return db; if (db != null) return db;
try try
{ {
db = getDb(new URI(uri)); db = getDb(new URI(uri));
@ -91,17 +92,17 @@ public class MStore
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
uri2db.put(uri, db); uri2db.put(uri, db);
return db; return db;
} }
public static Db getDb() public static Db getDb()
{ {
return getDb(ConfServer.dburi); return getDb(ConfServer.dburi);
} }
public static Db getDb(URI uri) public static Db getDb(URI uri)
{ {
String scheme = uri.getScheme(); String scheme = uri.getScheme();
@ -109,5 +110,15 @@ public class MStore
if (driver == null) return null; if (driver == null) return null;
return driver.getDb(uri.toString()); return driver.getDb(uri.toString());
} }
// -------------------------------------------- //
// OTHER
// -------------------------------------------- //
public static boolean isLocalPollingDebugEnabled()
{
return ConfServer.localPollingEnabled && MassiveCoreMConf.get().warnOnLocalAlter;
}
} }