### Question:
AcknowledgeSupport { public static long[] sortMsgLocation(MessageLocation[] locationArr) { int originalSize = locationArr.length; String topic = locationArr[0].getTopic(); int partition = locationArr[0].getPartition(); long minIndex = locationArr[0].getIndex(); long maxIndex = locationArr[0].getIndex(); Set<Long> set = new HashSet<>(originalSize); for (MessageLocation item : locationArr) { if (!StringUtils.equals(topic, item.getTopic()) || partition != item.getPartition()){ return null; } long index = item.getIndex(); set.add(index); if (index <= minIndex) { minIndex = index; } else if (index > maxIndex){ maxIndex = index; } } int currentSize = set.size(); long newMaxIndex = minIndex + set.size() - 1; long[] rst = null; if (originalSize == currentSize && maxIndex == newMaxIndex) { rst = new long[]{minIndex, maxIndex}; } return rst; }  static long[] sortMsgLocation(MessageLocation[] locationArr);  }### Answer:
@Test public void sortMsgLocation() { String topic = "topic"; short app = 1; List<MessageLocation> list = new ArrayList<>(); for (int i = 0; i < 7; i++) { MessageLocation messageLocation = new MessageLocation(topic, app, (long) i); list.add(messageLocation); } long[] longs = AcknowledgeSupport.sortMsgLocation(list.toArray(new MessageLocation[]{})); System.out.println(Arrays.toString(longs)); }