Source:
private SourceInfoResponse getFanoutSourceInfo(SourceInfoRequest sourceInfoRequest) throws SourceUnavailableException { SourceInfoResponse response; SourceDescriptorImpl sourceDescriptor; try { if (sourceInfoRequest == null) { throw new IllegalArgumentException("SourceInfoRequest was null"); } Set<SourceDescriptor> sourceDescriptors = new LinkedHashSet<>(); Set<String> ids = sourceInfoRequest.getSourceIds(); if (ids != null) { Optional<String> notLocal = ids.stream().filter(s -> !s.equals(getId())).findFirst(); if (notLocal.isPresent()) { SourceUnavailableException sourceUnavailableException = new SourceUnavailableException("Unknown source: " + notLocal.get()); LOGGER.debug( "Throwing SourceUnavailableException for unknown source: {}", notLocal.get(), sourceUnavailableException); throw sourceUnavailableException; } } final List<Source> availableSources = Stream.concat( frameworkProperties.getFederatedSources().values().stream(), Stream.of(catalog).filter(Objects::nonNull)) .filter(this::isSourceAvailable) .collect(Collectors.toList()); final Set<ContentType> contentTypes = new HashSet<>(); for (Source availableSource : availableSources) { final Set<ContentType> contentTypesForSource = contentTypesCache .getCachedValueForSource(availableSource) .orElseThrow( () -> new IllegalStateException( "Expected known cached ContentTypes in the Cache for source id=" + availableSource.getId() + " because the the source was last known to be available")); contentTypes.addAll(contentTypesForSource); } List<Action> actions = getSourceActions(catalog); sourceDescriptor = new SourceDescriptorImpl(this.getId(), contentTypes, actions); if (this.getVersion() != null) { sourceDescriptor.setVersion(this.getVersion()); } sourceDescriptor.setAvailable(!availableSources.isEmpty()); sourceDescriptors.add(sourceDescriptor); response = new SourceInfoResponseImpl(sourceInfoRequest, null, sourceDescriptors); } catch (RuntimeException re) { throw new SourceUnavailableException( "Exception during runtime while performing getSourceInfo", re); } return response; }

Target:
private SourceInfoResponse getFanoutSourceInfo(SourceInfoRequest sourceInfoRequest) throws SourceUnavailableException { SourceInfoResponse response; SourceDescriptorImpl sourceDescriptor; try { if (sourceInfoRequest == null) { throw new IllegalArgumentException("SourceInfoRequest was null"); } Set<SourceDescriptor> sourceDescriptors = new LinkedHashSet<>(); Set<String> ids = sourceInfoRequest.getSourceIds(); if (ids != null) { Optional<String> notLocal = ids.stream().filter(s -> !s.equals(getId())).findFirst(); if (notLocal.isPresent()) { SourceUnavailableException sourceUnavailableException = new SourceUnavailableException("Unknown source: " + notLocal.get()); LOGGER.debug( "Throwing SourceUnavailableException for unknown source: {}", notLocal.get(), sourceUnavailableException); throw sourceUnavailableException; } } final List<Source> availableSources = frameworkProperties .getFederatedSources() .stream() .filter(this::isSourceAvailable) .collect(Collectors.toList()); final Set<ContentType> contentTypes = availableSources .stream() .map( source -> contentTypesCache .getCachedValueForSource(source) .orElseGet( () -> { LOGGER.debug( "Unknown content types for source id={}", source.getId()); return Collections.emptySet(); })) .flatMap(Collection::stream) .collect(Collectors.toSet()); if (isSourceAvailable(catalog)) { availableSources.add(catalog); final Optional<Set<ContentType>> catalogContentTypes = contentTypesCache.getCachedValueForSource(catalog); if (catalogContentTypes.isPresent()) { contentTypes.addAll(catalogContentTypes.get()); } else { LOGGER.debug("Unknown content types for the localSource"); } } List<Action> actions = getSourceActions(catalog); sourceDescriptor = new SourceDescriptorImpl(this.getId(), contentTypes, actions); if (this.getVersion() != null) { sourceDescriptor.setVersion(this.getVersion()); } sourceDescriptor.setAvailable(!availableSources.isEmpty()); sourceDescriptors.add(sourceDescriptor); response = new SourceInfoResponseImpl(sourceInfoRequest, null, sourceDescriptors); } catch (RuntimeException re) { throw new SourceUnavailableException( "Exception during runtime while performing getSourceInfo", re); } return response; }