提交 d93b233a 编写于 作者: R Raj 提交者: Matteo Merli

Replace Collections.sort(list) with list.sort() to support earlier jdk-version...

Replace Collections.sort(list) with list.sort() to support earlier jdk-version than jdk-1.8.0_20 (#24)

Fixes #20 
上级 b2cbf4e8
......@@ -44,7 +44,7 @@ public class EntryCacheDefaultEvictionPolicy implements EntryCacheEvictionPolicy
checkArgument(sizeToFree > 0);
checkArgument(!caches.isEmpty());
Collections.sort(caches, reverseOrder());
caches.sort(reverseOrder());
long totalSize = 0;
for (EntryCache cache : caches) {
......
......@@ -19,7 +19,6 @@ import static com.google.common.base.Preconditions.checkArgument;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Set;
......@@ -207,7 +206,7 @@ public abstract class AdminResource extends PulsarWebResource {
}
}
Collections.sort(namespaces);
namespaces.sort(null);
return namespaces;
}
......
......@@ -132,7 +132,7 @@ public class Namespaces extends AdminResource {
throw new RestException(e);
}
Collections.sort(namespaces);
namespaces.sort(null);
return namespaces;
}
......
......@@ -147,7 +147,7 @@ public class PersistentTopics extends AdminResource {
throw new RestException(e);
}
Collections.sort(destinations);
destinations.sort(null);
return destinations;
}
......
......@@ -58,7 +58,7 @@ public class Properties extends AdminResource {
try {
List<String> properties = globalZk().getChildren(path("policies"), false);
Collections.sort(properties);
properties.sort(null);
return properties;
} catch (Exception e) {
log.error("[{}] Failed to get properties list", clientAppId(), e);
......
......@@ -668,7 +668,7 @@ public class NamespaceService {
// NoNode means there are no persistent topics for this namespace
}
Collections.sort(destinations);
destinations.sort(null);
return destinations;
}
......
......@@ -72,7 +72,7 @@ public final class PersistentDispatcherSingleActiveConsumer implements Dispatche
private void pickAndScheduleActiveConsumer() {
checkArgument(!consumers.isEmpty());
Collections.sort(consumers, (c1, c2) -> c1.consumerName().compareTo(c2.consumerName()));
consumers.sort((c1, c2) -> c1.consumerName().compareTo(c2.consumerName()));
int index = partitionIndex % consumers.size();
Consumer prevConsumer = activeConsumer.getAndSet(consumers.get(index));
......
......@@ -198,12 +198,12 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
public void testGetNamespaces() throws Exception {
List<String> expectedList = Lists.newArrayList(this.testLocalNamespaces.get(0).toString(),
this.testLocalNamespaces.get(1).toString());
Collections.sort(expectedList);
expectedList.sort(null);
assertEquals(namespaces.getNamespacesForCluster(this.testProperty, this.testLocalCluster), expectedList);
expectedList = Lists.newArrayList(this.testLocalNamespaces.get(0).toString(),
this.testLocalNamespaces.get(1).toString(), this.testLocalNamespaces.get(2).toString(),
this.testGlobalNamespaces.get(0).toString());
Collections.sort(expectedList);
expectedList.sort(null);
assertEquals(namespaces.getPropertyNamespaces(this.testProperty), expectedList);
try {
......@@ -620,7 +620,7 @@ public class NamespacesTest extends MockedPulsarServiceBaseTest {
namespaces.deleteNamespace(testNs.getProperty(), testNs.getCluster(), testNs.getLocalName(), false);
List<String> nsList = Lists.newArrayList(this.testLocalNamespaces.get(1).toString(),
this.testLocalNamespaces.get(2).toString());
Collections.sort(nsList);
nsList.sort(null);
assertEquals(namespaces.getPropertyNamespaces(this.testProperty), nsList);
testNs = this.testLocalNamespaces.get(1);
......
......@@ -253,21 +253,21 @@ public class ConcurrentLongHashMapTest {
map.put(2, "two");
List<Long> keys = map.keys();
Collections.sort(keys);
keys.sort(null);
assertEquals(keys, Lists.newArrayList(0l, 1l, 2l));
List<String> values = map.values();
Collections.sort(values);
values.sort(null);
assertEquals(values, Lists.newArrayList("one", "two", "zero"));
map.put(1, "uno");
keys = map.keys();
Collections.sort(keys);
keys.sort(null);
assertEquals(keys, Lists.newArrayList(0l, 1l, 2l));
values = map.values();
Collections.sort(values);
values.sort(null);
assertEquals(values, Lists.newArrayList("two", "uno", "zero"));
map.clear();
......
......@@ -239,21 +239,21 @@ public class ConcurrentOpenHashMapTest {
map.put(2l, "two");
List<Long> keys = map.keys();
Collections.sort(keys);
keys.sort(null);
assertEquals(keys, Lists.newArrayList(0l, 1l, 2l));
List<String> values = map.values();
Collections.sort(values);
values.sort(null);
assertEquals(values, Lists.newArrayList("one", "two", "zero"));
map.put(1l, "uno");
keys = map.keys();
Collections.sort(keys);
keys.sort(null);
assertEquals(keys, Lists.newArrayList(0l, 1l, 2l));
values = map.values();
Collections.sort(values);
values.sort(null);
assertEquals(values, Lists.newArrayList("two", "uno", "zero"));
map.clear();
......
......@@ -226,7 +226,7 @@ public class ConcurrentOpenHashSetTest {
set.add(2l);
List<Long> values = set.values();
Collections.sort(values);
values.sort(null);
assertEquals(values, Lists.newArrayList(0l, 1l, 2l));
set.clear();
......@@ -244,14 +244,14 @@ public class ConcurrentOpenHashSetTest {
set.add(7);
List<Integer> values = set.values();
Collections.sort(values);
values.sort(null);
assertEquals(values, Lists.newArrayList(0, 1, 3, 6, 7));
int numOfItemsDeleted = set.removeIf(i -> i < 5);
assertEquals(numOfItemsDeleted, 3);
assertEquals(set.size(), values.size() - numOfItemsDeleted);
values = set.values();
Collections.sort(values);
values.sort(null);
assertEquals(values, Lists.newArrayList(6, 7));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册