diff --git a/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java b/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java index 805b9e414c..b80a99f77c 100644 --- a/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java +++ b/codec/src/main/java/io/netty/handler/codec/DefaultHeaders.java @@ -14,7 +14,6 @@ */ package io.netty.handler.codec; -import io.netty.util.collection.CollectionUtils; import io.netty.util.collection.IntObjectHashMap; import io.netty.util.collection.IntObjectMap; import io.netty.util.concurrent.FastThreadLocal; @@ -1147,7 +1146,7 @@ public class DefaultHeaders implements Headers { // because we want to force the keyComparator to be used for all comparisons List namesList = namesList(); List otherNamesList = h2.namesList(); - if (!CollectionUtils.equals(namesList, otherNamesList, keyComparator)) { + if (!equals(namesList, otherNamesList, keyComparator)) { return false; } @@ -1156,7 +1155,7 @@ public class DefaultHeaders implements Headers { Set names = new TreeSet(keyComparator); names.addAll(namesList); for (T name : names) { - if (!CollectionUtils.equals(getAll(name), h2.getAll(name), valueComparator)) { + if (!equals(getAll(name), h2.getAll(name), valueComparator)) { return false; } } @@ -1164,6 +1163,31 @@ public class DefaultHeaders implements Headers { return true; } + /** + * Compare two lists using the {@code comparator} for all comparisons (not using the equals() operator) + * @param lhs Left hand side + * @param rhs Right hand side + * @param comparator Comparator which will be used for all comparisons (equals() on objects will not be used) + * @return True if {@code lhs} == {@code rhs} according to {@code comparator}. False otherwise. + */ + private static boolean equals(List lhs, List rhs, Comparator comparator) { + final int lhsSize = lhs.size(); + if (lhsSize != rhs.size()) { + return false; + } + + // Don't use a TreeSet to do the comparison. We want to force the comparator + // to be used instead of the object's equals() + Collections.sort(lhs, comparator); + Collections.sort(rhs, comparator); + for (int i = 0; i < lhsSize; ++i) { + if (comparator.compare(lhs.get(i), rhs.get(i)) != 0) { + return false; + } + } + return true; + } + @Override public int hashCode() { int result = 1; diff --git a/common/src/main/java/io/netty/util/collection/CollectionUtils.java b/common/src/main/java/io/netty/util/collection/CollectionUtils.java deleted file mode 100644 index b9e11044c4..0000000000 --- a/common/src/main/java/io/netty/util/collection/CollectionUtils.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 2014 The Netty Project - * - * The Netty Project licenses this file to you under the Apache License, version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at: - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package io.netty.util.collection; - -import java.util.Collections; -import java.util.Comparator; -import java.util.List; - -/** - * Provides utilities for the primitive collection types that are not supplied by the JDK - */ -public final class CollectionUtils { - - private CollectionUtils() { } - - /** - * Compare two lists using the {@code comparator} for all comparisons (not using the equals() operator) - * @param lhs Left hand side - * @param rhs Right hand side - * @param comparator Comparator which will be used for all comparisons (equals() on objects will not be used) - * @return True if {@code lhs} == {@code rhs} according to {@code comparator}. False otherwise. - */ - public static boolean equals(List lhs, List rhs, Comparator comparator) { - final int lhsSize = lhs.size(); - if (lhsSize != rhs.size()) { - return false; - } - - // Don't use a TreeSet to do the comparison. We want to force the comparator - // to be used instead of the object's equals() - Collections.sort(lhs, comparator); - Collections.sort(rhs, comparator); - for (int i = 0; i < lhsSize; ++i) { - if (comparator.compare(lhs.get(i), rhs.get(i)) != 0) { - return false; - } - } - return true; - } -}