PaperMC/Spigot-Server-Patches/0542-Fix-AdvancementDataPlayer-leak-due-from-quitting-ear.patch
Daniel Ennis c97ce029e9
1.16.2 Release (#4123)
PaperMC believes that 1.16.2 is now ready for general release as we fixed the main issue plagueing the 1.16.x release, the MapLike data conversion issues.

Until now, it was not safe for a server to convert a world to 1.16.2 without data conversion issues around villages and potentially other things. If you did, those MapLike errors meant something went wrong.

This is now resolved.

Big thanks to all those that helped, notably @BillyGalbreath and @Proximyst who did large parts of the update process with me.

Please as always, backup your worlds and test before updating to 1.16.2!

If you update to 1.16.2, there is no going back to an older build than this.

---------------------------------

Co-authored-by: William Blake Galbreath <Blake.Galbreath@GMail.com>
Co-authored-by: Mariell Hoversholm <proximyst@proximyst.com>
Co-authored-by: krolik-exe <69214078+krolik-exe@users.noreply.github.com>
Co-authored-by: BillyGalbreath <BillyGalbreath@users.noreply.github.com>
Co-authored-by: stonar96 <minecraft.stonar96@gmail.com>
Co-authored-by: Shane Freeder <theboyetronic@gmail.com>
Co-authored-by: Jason <jasonpenilla2@me.com>
Co-authored-by: kashike <kashike@vq.lc>
Co-authored-by: Aurora <21148213+aurorasmiles@users.noreply.github.com>
Co-authored-by: KennyTV <kennytv@t-online.de>
Co-authored-by: commandblockguy <commandblockguy1@gmail.com>
Co-authored-by: DigitalRegent <misterwener@gmail.com>
Co-authored-by: ishland <ishlandmc@yeah.net>
2020-08-24 22:40:19 -04:00

86 lines
4.8 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <spottedleaf@spottedleaf.dev>
Date: Mon, 13 Jul 2020 06:22:54 -0700
Subject: [PATCH] Fix AdvancementDataPlayer leak due from quitting early in
login
Move the criterion storage to the AdvancementDataPlayer object
itself, so the criterion object stores no references - and thus
needs no cleanup.
diff --git a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
index d3387a4e16f81b820d40502d2c46ebb3db88f824..17789407b9e86896a963a305a13357286aa5f319 100644
--- a/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
+++ b/src/main/java/net/minecraft/server/AdvancementDataPlayer.java
@@ -51,6 +51,10 @@ public class AdvancementDataPlayer {
private Advancement l;
private boolean m = true;
+ // Paper start - fix advancement data player leakage
+ final Map<CriterionTriggerAbstract, Set<CriterionTrigger.a>> criterionData = Maps.newIdentityHashMap();
+ // Paper end - fix advancement data player leakage
+
public AdvancementDataPlayer(DataFixer datafixer, PlayerList playerlist, AdvancementDataWorld advancementdataworld, File file, EntityPlayer entityplayer) {
this.d = datafixer;
this.e = playerlist;
diff --git a/src/main/java/net/minecraft/server/CriterionTriggerAbstract.java b/src/main/java/net/minecraft/server/CriterionTriggerAbstract.java
index 2419c57f90f40516cb4b4cedcda2c7d58523c3bc..5fd81933f8ba30d165fb3fdf25aaf94917637539 100644
--- a/src/main/java/net/minecraft/server/CriterionTriggerAbstract.java
+++ b/src/main/java/net/minecraft/server/CriterionTriggerAbstract.java
@@ -12,25 +12,25 @@ import java.util.function.Predicate;
public abstract class CriterionTriggerAbstract<T extends CriterionInstanceAbstract> implements CriterionTrigger<T> {
- private final Map<AdvancementDataPlayer, Set<CriterionTrigger.a<T>>> a = Maps.newIdentityHashMap();
+ //private final Map<AdvancementDataPlayer, Set<CriterionTrigger.a<T>>> a = Maps.newIdentityHashMap(); // Paper - moved into AdvancementDataPlayer to fix memory leak
public CriterionTriggerAbstract() {}
@Override
public final void a(AdvancementDataPlayer advancementdataplayer, CriterionTrigger.a<T> criteriontrigger_a) {
- ((Set) this.a.computeIfAbsent(advancementdataplayer, (advancementdataplayer1) -> {
+ (advancementdataplayer.criterionData.computeIfAbsent(this, (advancementdataplayer1) -> { // Paper - fix AdvancementDataPlayer leak
return Sets.newHashSet();
})).add(criteriontrigger_a);
}
@Override
public final void b(AdvancementDataPlayer advancementdataplayer, CriterionTrigger.a<T> criteriontrigger_a) {
- Set<CriterionTrigger.a<T>> set = (Set) this.a.get(advancementdataplayer);
+ Set<CriterionTrigger.a<T>> set = (Set) advancementdataplayer.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak
if (set != null) {
set.remove(criteriontrigger_a);
if (set.isEmpty()) {
- this.a.remove(advancementdataplayer);
+ advancementdataplayer.criterionData.remove(this); // Paper - fix AdvancementDataPlayer leak
}
}
@@ -38,7 +38,7 @@ public abstract class CriterionTriggerAbstract<T extends CriterionInstanceAbstra
@Override
public final void a(AdvancementDataPlayer advancementdataplayer) {
- this.a.remove(advancementdataplayer);
+ advancementdataplayer.criterionData.remove(this); // Paper - fix AdvancementDataPlayer leak
}
protected abstract T b(JsonObject jsonobject, CriterionConditionEntity.b criterionconditionentity_b, LootDeserializationContext lootdeserializationcontext);
@@ -52,7 +52,7 @@ public abstract class CriterionTriggerAbstract<T extends CriterionInstanceAbstra
protected void a(EntityPlayer entityplayer, Predicate<T> predicate) {
AdvancementDataPlayer advancementdataplayer = entityplayer.getAdvancementData();
- Set<CriterionTrigger.a<T>> set = (Set) this.a.get(advancementdataplayer);
+ Set<CriterionTrigger.a<T>> set = (Set) advancementdataplayer.criterionData.get(this); // Paper - fix AdvancementDataPlayer leak
if (set != null && !set.isEmpty()) {
LootTableInfo loottableinfo = CriterionConditionEntity.b(entityplayer, entityplayer);
@@ -63,7 +63,7 @@ public abstract class CriterionTriggerAbstract<T extends CriterionInstanceAbstra
while (iterator.hasNext()) {
criteriontrigger_a = (CriterionTrigger.a) iterator.next();
- T t0 = (CriterionInstanceAbstract) criteriontrigger_a.a();
+ T t0 = (T) criteriontrigger_a.a(); // Paper - decompile fix
if (t0.b().a(loottableinfo) && predicate.test(t0)) {
if (list == null) {