From d5914e52e1ab1de54be2afa04aaaa9221e214b81 Mon Sep 17 00:00:00 2001 From: flamin_scotsman Date: Fri, 13 Mar 2015 16:04:55 +0000 Subject: [PATCH] Fix ExceptionHandler compareTo method. The previous implementation violated the contract that compareTo must be behave the same way when operands are reversed and that it is transitive. Any classes that were not equal, or a superclass of another were returned as being "less than". The new implementation tests if classes are superclasses of each other, otherwise falls back to alphabetical sorting on canonical name. While this did not manifest in 1.6, the replacement sort algorithm in 1.8 (TimSort) caused the sorting to appear random due to apparently contiguous sections being consumed, then sorted in bulk. --- .../util/command/parametric/ExceptionConverterHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java index 177e5a899..2341e5816 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/command/parametric/ExceptionConverterHelper.java @@ -100,8 +100,10 @@ public abstract class ExceptionConverterHelper implements ExceptionConverter { return 0; } else if (cls.isAssignableFrom(o.cls)) { return 1; - } else { + } else if (o.cls.isAssignableFrom(cls)) { return -1; + } else { + return cls.getCanonicalName().compareTo(o.cls.getCanonicalName()); } } }