Serguey Asael Shinder: StringBuilder does not override equals, so two builders with the same text are unequal
This check looks harmless:
StringBuilder a = new StringBuilder("order-42");
StringBuilder b = new StringBuilder("order-42");
a.equals(b); // false
a.compareTo(b); // 0

Both builders hold the same eight characters, and the comparison method agrees they are the same. equals disagrees, because it was never written for this class. The javadoc of java.lang.StringBuilder says so in an API note: "StringBuilder implements Comparable but does not override equals. Thus, the natural ordering of StringBuilder is inconsistent with equals." What a.equals(b) runs is Object.equals, which asks whether a and b are the same object.
The compareTo method arrived in Java 11, and the javadoc defines it by reference: it "follows the same rules for lexicographical comparison as defined in the CharSequence.compare(this, another) method". So since 11 there are two answers to "are these the same", and they can differ.
The javadoc names where that bites: "Care should be exercised if StringBuilder objects are used as keys in a SortedMap or elements in a SortedSet." A TreeSet<StringBuilder> uses compareTo and will treat two builders with equal text as one element; a HashSet<StringBuilder> uses equals and hashCode and will keep both. The same data, two collections, two different sizes. There is a second, quieter problem: a builder is mutable, so a builder stored as a key can change after it went into the map.
Three habits follow. To compare a builder's content with a string, use String.contentEquals(CharSequence), which is true "if and only if this String represents the same sequence of char values as the specified sequence". To compare two builders, use CharSequence.compare(a, b) == 0 and say what you mean. And do not use a StringBuilder as a key at all: call toString() when the text is complete and store the immutable String, whose equals compares content.