This is an automated email from the ASF dual-hosted git repository.
av pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git
The following commit(s) were added to refs/heads/master by this push:
new 44085fa17dc IGNITE-17865 Disable partition ranges in log messages by
default (#10352)
44085fa17dc is described below
commit 44085fa17dc63f1d0a0e4e10f31a5b751c9d8cd7
Author: Ilya Shishkov <[email protected]>
AuthorDate: Tue Nov 29 13:17:34 2022 +0300
IGNITE-17865 Disable partition ranges in log messages by default (#10352)
---
.../dht/preloader/GridDhtPartitionDemander.java | 6 ++--
.../dht/preloader/GridDhtPartitionSupplier.java | 4 +--
.../preloader/GridDhtPartitionsExchangeFuture.java | 2 +-
.../dht/topology/GridClientPartitionTopology.java | 4 +--
.../dht/topology/GridDhtPartitionTopologyImpl.java | 6 ++--
.../dht/topology/PartitionsEvictManager.java | 2 +-
.../persistence/snapshot/SnapshotFutureTask.java | 13 +++++----
.../SnapshotPartitionsQuickVerifyHandler.java | 2 +-
.../snapshot/SnapshotRestoreProcess.java | 6 ++--
.../util/tostring/GridToStringBuilder.java | 16 +++++-----
.../dht/topology/EvictPartitionInLogTest.java | 34 +++++-----------------
.../db/wal/IgniteWalRebalanceLoggingTest.java | 8 ++---
.../util/tostring/GridToStringBuilderSelfTest.java | 16 ++++------
13 files changed, 50 insertions(+), 69 deletions(-)
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
index 9d168a0b50a..b5f42214ad3 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionDemander.java
@@ -558,7 +558,7 @@ public class GridDhtPartitionDemander {
U.error(log, "Rebalancing routine has failed, some partitions
could be unavailable for reading" +
" [" + demandRoutineInfo(nodeId, supplyMsg) +
- ", unavailablePartitions=" + S.compact(unstableParts) +
']', msgExc);
+ ", unavailablePartitions=" +
S.toStringSortedDistinct(unstableParts) + ']', msgExc);
fut.error(nodeId);
@@ -1431,8 +1431,8 @@ public class GridDhtPartitionDemander {
log.info("Starting rebalance routine [" +
grp.cacheOrGroupName() +
", topVer=" + topVer +
", supplier=" + supplierNode.id() +
- ", fullPartitions=" + S.compact(parts.fullSet()) +
- ", histPartitions=" + S.compact(parts.historicalSet())
+
+ ", fullPartitions=" +
S.toStringSortedDistinct(parts.fullSet()) +
+ ", histPartitions=" +
S.toStringSortedDistinct(parts.historicalSet()) +
", rebalanceId=" + rebalanceId + ']');
ctx.io().sendOrderedMessage(supplierNode, msg.topic(),
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
index d4264d45412..d6cbd8e1267 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionSupplier.java
@@ -273,8 +273,8 @@ public class GridDhtPartitionSupplier {
if (sctx == null) {
if (log.isDebugEnabled())
log.debug("Starting supplying rebalancing [" +
supplyRoutineInfo(topicId, nodeId, demandMsg) +
- ", fullPartitions=" +
S.compact(demandMsg.partitions().fullSet()) +
- ", histPartitions=" +
S.compact(demandMsg.partitions().historicalSet()) + "]");
+ ", fullPartitions=" +
S.toStringSortedDistinct(demandMsg.partitions().fullSet()) +
+ ", histPartitions=" +
S.toStringSortedDistinct(demandMsg.partitions().historicalSet()) + "]");
}
else
maxBatchesCnt = 1;
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
index faf80aa04a9..75280a76f5d 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/preloader/GridDhtPartitionsExchangeFuture.java
@@ -4283,7 +4283,7 @@ public class GridDhtPartitionsExchangeFuture extends
GridDhtTopologyFutureAdapte
if (hasPartitionToLog(supplyInfoMap, false)) {
log.info("Partitions weren't present in any history
reservation: [" +
supplyInfoMap.entrySet().stream().map(entry ->
- "[grp=" + entry.getKey() + " part=[" +
S.compact(entry.getValue().stream()
+ "[grp=" + entry.getKey() + " part=[" +
S.toStringSortedDistinct(entry.getValue().stream()
.filter(info -> !info.isHistoryReserved())
.map(info ->
info.part()).collect(Collectors.toSet())) + "]]"
).collect(Collectors.joining(", ")) + ']');
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridClientPartitionTopology.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridClientPartitionTopology.java
index 08b240a8fce..6adbb53a692 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridClientPartitionTopology.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridClientPartitionTopology.java
@@ -1308,8 +1308,8 @@ public class GridClientPartitionTopology implements
GridDhtPartitionTopology {
U.warn(log, "Partitions have been scheduled for
rebalancing due to outdated update counter "
+ "[grpId=" + grpId
+ ", nodeId=" + nodeId
- + ", partsFull=" + S.compact(partsToRebalance)
- + ", partsHistorical=" + S.compact(historical) + "]");
+ + ", partsFull=" +
S.toStringSortedDistinct(partsToRebalance)
+ + ", partsHistorical=" +
S.toStringSortedDistinct(historical) + "]");
}
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java
index e85453d76f0..818cf7eef0e 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/GridDhtPartitionTopologyImpl.java
@@ -2278,7 +2278,7 @@ public class GridDhtPartitionTopologyImpl implements
GridDhtPartitionTopology {
if (recentlyLost != null) {
U.warn(log, "Detected lost partitions" + (!safe ? " (will
ignore)" : "")
+ " [grp=" + grp.cacheOrGroupName()
- + ", parts=" + S.compact(recentlyLost)
+ + ", parts=" + S.toStringSortedDistinct(recentlyLost)
+ ", topVer=" + resTopVer + "]");
}
@@ -2442,8 +2442,8 @@ public class GridDhtPartitionTopologyImpl implements
GridDhtPartitionTopology {
+ ", readyTopVer=" + readyTopVer
+ ", topVer=" + exchFut.initialVersion()
+ ", nodeId=" + nodeId
- + ", partsFull=" + S.compact(rebalancedParts)
- + ", partsHistorical=" + S.compact(historical) +
"]");
+ + ", partsFull=" +
S.toStringSortedDistinct(rebalancedParts)
+ + ", partsHistorical=" +
S.toStringSortedDistinct(historical) + "]");
}
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/PartitionsEvictManager.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/PartitionsEvictManager.java
index 9ab94a56bbb..c7110a351cf 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/PartitionsEvictManager.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/PartitionsEvictManager.java
@@ -251,7 +251,7 @@ public class PartitionsEvictManager extends
GridCacheSharedManagerAdapter {
StringJoiner joiner = new StringJoiner(", ");
- partByReason.forEach((reason, partIds) -> joiner.add(reason.toString()
+ '=' + S.compact(partIds)));
+ partByReason.forEach((reason, partIds) -> joiner.add(reason.toString()
+ '=' + S.toStringSortedDistinct(partIds)));
return joiner.toString();
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java
index d453d3f782e..797fcba2d18 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotFutureTask.java
@@ -403,7 +403,7 @@ class SnapshotFutureTask extends
AbstractSnapshotFutureTask<Set<GroupPartitionId
if (!missed.isEmpty()) {
throw new IgniteCheckedException("Snapshot operation
cancelled due to " +
"not all of requested partitions has OWNING state
on local node [grpId=" + grpId +
- ", missed=" + S.compact(missed) + ']');
+ ", missed=" + S.toStringSortedDistinct(missed) +
']');
}
}
else {
@@ -412,7 +412,7 @@ class SnapshotFutureTask extends
AbstractSnapshotFutureTask<Set<GroupPartitionId
if (!missed.isEmpty()) {
log.warning("All local cache group partitions in
OWNING state have been included into a snapshot. " +
"Partitions which have different states skipped.
Index partitions has also been skipped " +
- "[snpName=" + snpName + ", grpId=" + grpId + ",
missed=" + S.compact(missed) + ']');
+ "[snpName=" + snpName + ", grpId=" + grpId + ",
missed=" + S.toStringSortedDistinct(missed) + ']');
}
else if (affNode && missed.isEmpty() &&
cctx.kernalContext().query().moduleEnabled())
owning.add(INDEX_PARTITION);
@@ -471,7 +471,7 @@ class SnapshotFutureTask extends
AbstractSnapshotFutureTask<Set<GroupPartitionId
if (log.isInfoEnabled()) {
log.info("Submit partition processing tasks to the snapshot
execution pool " +
- "[map=" + compactGroupPartitions(partFileLengths.keySet()) +
+ "[map=" + groupByGroupId(partFileLengths.keySet()) +
", totalSize=" +
U.humanReadableByteCount(partFileLengths.values().stream().mapToLong(v ->
v).sum()) + ']');
}
@@ -667,16 +667,17 @@ class SnapshotFutureTask extends
AbstractSnapshotFutureTask<Set<GroupPartitionId
/**
* @param grps List of processing pairs.
- * @return Map of cache group id their partitions compacted by {@link
S#compact(Collection)}.
+ *
+ * @return Map with cache group id's associated to corresponding
partitions.
*/
- private static Map<Integer, String>
compactGroupPartitions(Collection<GroupPartitionId> grps) {
+ private static Map<Integer, String>
groupByGroupId(Collection<GroupPartitionId> grps) {
return grps.stream()
.collect(Collectors.groupingBy(GroupPartitionId::getGroupId,
Collectors.mapping(GroupPartitionId::getPartitionId,
Collectors.toSet())))
.entrySet()
.stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e ->
S.compact(e.getValue())));
+ .collect(Collectors.toMap(Map.Entry::getKey, e ->
S.toStringSortedDistinct(e.getValue())));
}
/** {@inheritDoc} */
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsQuickVerifyHandler.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsQuickVerifyHandler.java
index 97a94e0313b..0fcebb21d95 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsQuickVerifyHandler.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotPartitionsQuickVerifyHandler.java
@@ -88,7 +88,7 @@ public class SnapshotPartitionsQuickVerifyHandler extends
SnapshotPartitionsVeri
}));
if (!wrnGrps.isEmpty()) {
- throw new SnapshotHandlerWarningException("Cache partitions differ
for cache groups " + S.compact(wrnGrps)
+ throw new SnapshotHandlerWarningException("Cache partitions differ
for cache groups " + S.toStringSortedDistinct(wrnGrps)
+ ". " + WRN_MSG);
}
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
index d41fdda28ca..4196f063d77 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/persistence/snapshot/SnapshotRestoreProcess.java
@@ -998,7 +998,7 @@ public class SnapshotRestoreProcess {
"[reqId=" + reqId +
", snapshot=" + opCtx0.snpName +
", map=" +
snpAff.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey,
- e -> partitionsMapToCompactString(e.getValue())))
+ ']');
+ e -> partitionsMapToString(e.getValue()))) + ']');
}
for (Map.Entry<UUID, Map<Integer, Set<Integer>>> m :
snpAff.entrySet()) {
@@ -1364,10 +1364,10 @@ public class SnapshotRestoreProcess {
* @param map Map of partitions and cache groups.
* @return String representation.
*/
- private static String partitionsMapToCompactString(Map<Integer,
Set<Integer>> map) {
+ private static String partitionsMapToString(Map<Integer, Set<Integer>>
map) {
return map.entrySet()
.stream()
- .collect(Collectors.toMap(Map.Entry::getKey, e ->
S.compact(e.getValue())))
+ .collect(Collectors.toMap(Map.Entry::getKey, e ->
S.toStringSortedDistinct(e.getValue())))
.toString();
}
diff --git
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
index 4871957d6b3..11eb3d9561a 100644
---
a/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
+++
b/modules/core/src/main/java/org/apache/ignite/internal/util/tostring/GridToStringBuilder.java
@@ -33,6 +33,7 @@ import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicReference;
import java.util.concurrent.locks.Condition;
@@ -1883,15 +1884,16 @@ public class GridToStringBuilder {
}
/**
- * Returns sorted and compacted string representation of given {@code col}.
- * Two nearby numbers with difference at most 1 are compacted to one
continuous segment.
- * E.g. collection of [1, 2, 3, 5, 6, 7, 10] will be compacted to [1-3,
5-7, 10].
+ * Creates string representation of a specified collection with
preliminary sorting and duplicates removing.
*
- * @param col Collection of integers.
- * @return Compacted string representation of given collections.
+ * @param c Input collection.
+ * @return String representation of collection.
*/
- public static String compact(Collection<Integer> col) {
- return compact(col, i -> i + 1);
+ public static String toStringSortedDistinct(Collection<? extends
Comparable<?>> c) {
+ if (c.isEmpty())
+ return "[]";
+
+ return '[' + F.concat(new TreeSet<>(c), ",") + ']';
}
/**
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/EvictPartitionInLogTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/EvictPartitionInLogTest.java
index 87c1475c40b..0a217301c25 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/EvictPartitionInLogTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/topology/EvictPartitionInLogTest.java
@@ -18,6 +18,7 @@
package org.apache.ignite.internal.processors.cache.distributed.dht.topology;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -26,13 +27,11 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.stream.IntStream;
import org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction;
import org.apache.ignite.configuration.CacheConfiguration;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.internal.IgniteEx;
import org.apache.ignite.internal.util.typedef.internal.CU;
-import org.apache.ignite.internal.util.typedef.internal.S;
import org.apache.ignite.testframework.ListeningTestLogger;
import org.apache.ignite.testframework.LogListener;
import org.apache.ignite.testframework.junits.WithSystemProperty;
@@ -227,8 +226,13 @@ public class EvictPartitionInLogTest extends
GridCommonAbstractTest {
//find and parsing grpId and partitions
if (grpIdMatcher.find() && partsMatcher.find()) {
-
evictParts.computeIfAbsent(parseInt(grpIdMatcher.group(1)), i -> new
ConcurrentLinkedQueue<>())
- .addAll(parseContentCompactStr(partsMatcher.group(1)));
+ List<Integer> parts = Arrays.stream(partsMatcher.group(1)
+ .split(","))
+ .map(Integer::parseInt)
+ .collect(toList());
+
+ evictParts.computeIfAbsent(parseInt(grpIdMatcher.group(1)),
+ i -> new ConcurrentLinkedQueue<>()).addAll(parts);
}
});
@@ -237,26 +241,4 @@ public class EvictPartitionInLogTest extends
GridCommonAbstractTest {
return builder.build();
}
-
- /**
- * Parse contents of compact string after a {@link S#compact(Collection)}.
- *
- * @param str Compact string content.
- * @return Parsed numbers.
- */
- private Collection<Integer> parseContentCompactStr(String str) {
- assertNotNull(str);
-
- return of(str.split(","))
- .map(String::trim)
- .flatMap(s -> {
- if (s.contains("-")) {
- String[] range = s.split("-");
-
- return IntStream.rangeClosed(parseInt(range[0]),
parseInt(range[1])).boxed();
- }
- else
- return of(parseInt(s));
- }).collect(toList());
- }
}
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceLoggingTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceLoggingTest.java
index 5ec42adf57f..ee743e6acfb 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceLoggingTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/persistence/db/wal/IgniteWalRebalanceLoggingTest.java
@@ -117,7 +117,7 @@ public class IgniteWalRebalanceLoggingTest extends
GridCommonAbstractTest {
str.contains("cache_group1") &&
str.contains("cache_group2")).times(3).
andMatches(str -> str.startsWith("Starting rebalance routine") &&
(str.contains("cache_group1") || str.contains("cache_group2"))
&&
- str.contains("fullPartitions=[],
histPartitions=[0-7]")).times(2).build();
+ str.contains("fullPartitions=[],
histPartitions=[0,1,2,3,4,5,6,7]")).times(2).build();
LogListener unexpectedMessagesLsnr = LogListener.matches((str) ->
str.startsWith("Partitions weren't present in any history
reservation:") ||
@@ -151,10 +151,10 @@ public class IgniteWalRebalanceLoggingTest extends
GridCommonAbstractTest {
public void testFullRebalanceLogMsgs() throws Exception {
LogListener expMsgsLsnr = LogListener.
matches("Partitions weren't present in any history reservation: " +
- "[[grp=cache_group2 part=[[0-7]]], [grp=cache_group1
part=[[0-7]]]]").
+ "[[grp=cache_group2 part=[[0,1,2,3,4,5,6,7]]],
[grp=cache_group1 part=[[0,1,2,3,4,5,6,7]]]]").
andMatches(str -> str.startsWith("Starting rebalance routine") &&
(str.contains("cache_group1") || str.contains("cache_group2"))
&&
- str.contains("fullPartitions=[0-7],
histPartitions=[]")).times(2).build();
+ str.contains("fullPartitions=[0,1,2,3,4,5,6,7],
histPartitions=[]")).times(2).build();
checkFollowingPartitionsWereReservedForPotentialHistoryRebalanceMsg(expMsgsLsnr);
@@ -176,7 +176,7 @@ public class IgniteWalRebalanceLoggingTest extends
GridCommonAbstractTest {
str.contains("grp=cache_group1") &&
str.contains("grp=cache_group2")).
andMatches(str -> str.startsWith("Starting rebalance routine") &&
(str.contains("cache_group1") || str.contains("cache_group2"))
&&
- str.contains("fullPartitions=[0-7],
histPartitions=[]")).times(2).build();
+ str.contains("fullPartitions=[0,1,2,3,4,5,6,7],
histPartitions=[]")).times(2).build();
checkFollowingPartitionsWereReservedForPotentialHistoryRebalanceMsg(expMsgsLsnr);
diff --git
a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
index d32f9f6274d..5324bd7efaa 100644
---
a/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
+++
b/modules/core/src/test/java/org/apache/ignite/internal/util/tostring/GridToStringBuilderSelfTest.java
@@ -597,22 +597,18 @@ public class GridToStringBuilderSelfTest extends
GridCommonAbstractTest {
/**
* Checking that method
- * {@link GridToStringBuilder#compact(Collection, Function) compact} works
+ * {@link GridToStringBuilder#toStringSortedDistinct(Collection)} works
* correctly for {@link Integer}.
*/
@Test
- public void testCompactIntegers() {
+ public void testSortedDistinctIntegers() {
List<Integer> emptyList = emptyList();
- List<Integer> intList = asList(1, 2, 3, 9, 8, 7, 12);
-
- String compactStr = "[1-3, 7-9, 12]";
-
- Function<Integer, Integer> nextVal = i -> i + 1;
+ List<Integer> intList = asList(12, 1, 7, 2, 3, 9, 8, 7, 12);
- checkCompact(emptyList, intList, nextVal, compactStr);
+ String sortedDistinctStr = "[1,2,3,7,8,9,12]";
- assertEquals("[]", compact(emptyList));
- assertEquals(compactStr, compact(intList));
+ assertEquals("[]", S.toStringSortedDistinct(emptyList));
+ assertEquals(sortedDistinctStr, S.toStringSortedDistinct(intList));
}
/**