From 56763aad0df7394696f204a9bf9f8483c114ee72 Mon Sep 17 00:00:00 2001 From: Brokkonaut Date: Fri, 20 Oct 2017 04:43:02 +0200 Subject: [PATCH] Replace HashSet with fastutil's ObjectOpenHashSet in HashTreeSet HashSet sometimes uses compareTo() instead of equals() and this breaks the comparison of net.minecraft.server.NextTickListEntry (the only place where HashTreeSet is used). In this cases duplicate entries could be added to the HashSet of HashTreeSet, because NextTickListEntry.compareTo() does not return 0, even if NextTickListEntry.equals() returns true. ObjectOpenHashSet never uses compareTo(), so the inconsistencies of NextTickListEntry cause no problems. Fixes https://github.com/PaperMC/Paper/issues/588 --- ...with-fastutil-s-ObjectOpenHashSet-in.patch | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Spigot-Server-Patches/Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch diff --git a/Spigot-Server-Patches/Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch b/Spigot-Server-Patches/Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch new file mode 100644 index 0000000000..ee5926838d --- /dev/null +++ b/Spigot-Server-Patches/Replace-HashSet-with-fastutil-s-ObjectOpenHashSet-in.patch @@ -0,0 +1,28 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Brokkonaut +Date: Fri, 20 Oct 2017 04:33:45 +0200 +Subject: [PATCH] Replace HashSet with fastutil's ObjectOpenHashSet in + HashTreeSet + +HashSet sometimes uses compareTo() instead of equals() and this breaks the comparison of net.minecraft.server.NextTickListEntry (the only place where HashTreeSet is used). + +In this cases duplicate entries could be added to the HashSet of HashTreeSet, because NextTickListEntry.compareTo() does not return 0, even if NextTickListEntry.equals() returns true. + +ObjectOpenHashSet never uses compareTo(), so the inconsistencies of NextTickListEntry cause no problems. + +Fixes https://github.com/PaperMC/Paper/issues/588 + +diff --git a/src/main/java/org/bukkit/craftbukkit/util/HashTreeSet.java b/src/main/java/org/bukkit/craftbukkit/util/HashTreeSet.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/util/HashTreeSet.java ++++ b/src/main/java/org/bukkit/craftbukkit/util/HashTreeSet.java +@@ -0,0 +0,0 @@ import java.util.TreeSet; + + public class HashTreeSet implements Set { + +- private HashSet hash = new HashSet(); ++ private Set hash = new it.unimi.dsi.fastutil.objects.ObjectOpenHashSet(); //Paper - Replace java.util.HashSet with ObjectOpenHashSet + private TreeSet tree = new TreeSet(); + + public HashTreeSet() { +-- \ No newline at end of file