Source:
private SubscriptionEventTypeStats loadStats( final EventType eventType, final ZkSubscriptionNode subscriptionNode, final ZkSubscriptionClient client, final List<PartitionEndStatistics> stats) { final Set<SubscriptionEventTypeStats.Partition> resultPartitions = new HashSet<>(stats.size()); for (final PartitionEndStatistics stat : stats) { final NakadiCursor lastPosition = stat.getLast(); if (!lastPosition.getEventType().equals(eventType.getName())) { continue; } Long distance; if (subscriptionNode.containsPartition(lastPosition.getEventTypePartition())) { final NakadiCursor currentPosition; final SubscriptionCursorWithoutToken offset = client.getOffset(new EventTypePartition(eventType.getName(), stat.getPartition())); try { currentPosition = converter.convert(offset); } catch (final InternalNakadiException | NoSuchEventTypeException | InvalidCursorException | ServiceUnavailableException e) { throw new MyNakadiRuntimeException1("Failed to convert cursor information for cursor ", e); } try { distance = cursorOperationsService.calculateDistance(currentPosition, lastPosition); } catch (final InvalidCursorOperation ex) { if (ex.getReason() == InvalidCursorOperation.Reason.INVERTED_TIMELINE_ORDER || ex.getReason() == InvalidCursorOperation.Reason.INVERTED_OFFSET_ORDER) { distance = 0L; } else { throw ex; } } } else { distance = null; } resultPartitions.add(new SubscriptionEventTypeStats.Partition( lastPosition.getPartition(), subscriptionNode.guessState(stat.getPartition()).getDescription(), distance, Optional.ofNullable(subscriptionNode.guessStream(stat.getPartition())).orElse("") )); } return new SubscriptionEventTypeStats(eventType.getName(), resultPartitions); }

Target:
private SubscriptionEventTypeStats loadStats( final EventType eventType, final ZkSubscriptionNode subscriptionNode, final ZkSubscriptionClient client, final List<PartitionEndStatistics> stats) throws ServiceTemporaryUnavailableException, InconsistentStateException { final Set<SubscriptionEventTypeStats.Partition> resultPartitions = new HashSet<>(stats.size()); for (final PartitionEndStatistics stat : stats) { final NakadiCursor lastPosition = stat.getLast(); if (!lastPosition.getEventType().equals(eventType.getName())) { continue; } Long distance; if (subscriptionNode.containsPartition(lastPosition.getEventTypePartition())) { final NakadiCursor currentPosition; final SubscriptionCursorWithoutToken offset = client.getOffset(new EventTypePartition(eventType.getName(), stat.getPartition())); try { currentPosition = converter.convert(offset); } catch (final InternalNakadiException | NoSuchEventTypeException | InvalidCursorException | ServiceUnavailableException e) { throw new ServiceTemporaryUnavailableException(e); } try { distance = cursorOperationsService.calculateDistance(currentPosition, lastPosition); } catch (final InvalidCursorOperation ex) { if (ex.getReason() == InvalidCursorOperation.Reason.INVERTED_TIMELINE_ORDER || ex.getReason() == InvalidCursorOperation.Reason.INVERTED_OFFSET_ORDER) { distance = 0L; } else { throw new InconsistentStateException("Unexpected exception while calculating distance", ex); } } } else { distance = null; } resultPartitions.add(new SubscriptionEventTypeStats.Partition( lastPosition.getPartition(), subscriptionNode.guessState(stat.getPartition()).getDescription(), distance, Optional.ofNullable(subscriptionNode.guessStream(stat.getPartition())).orElse("") )); } return new SubscriptionEventTypeStats(eventType.getName(), resultPartitions); }