Source:
private void cacheDomainEndpoints() { if (!initialized) { throw new IllegalStateException("CloudSearchEngine not initialized"); } if (!domainEndpointsCached) { final Set<String> managedDomains = new HashSet<>(); for (final DocumentConfiguration documentConfiguration : documentConfigurations.values()) { final String domainName = documentConfigurationHolder.schemaName() + "-" + documentConfiguration.namespace(); managedDomains.add(domainName); } final DescribeDomainsRequest describeDomainsRequest = new DescribeDomainsRequest(); describeDomainsRequest.setDomainNames(managedDomains); final DescribeDomainsResult describeDomainsResult = cloudSearchClient .describeDomains(describeDomainsRequest); final List<DomainStatus> domainStatusList = describeDomainsResult.getDomainStatusList(); if (domainStatusList.size() == managedDomains.size()) { for (final DomainStatus domainStatus : domainStatusList) { if (domainStatus.isCreated() && !domainStatus.isDeleted()) { final String documentServiceEndpoint = domainStatus.getDocService().getEndpoint(); final String searchServiceEndpoint = domainStatus.getSearchService().getEndpoint(); if (documentServiceEndpoint == null || searchServiceEndpoint == null) { domainEndpointsCached = false; return; } final AmazonCloudSearchDomain documentServiceClient = AmazonCloudSearchDomainClientBuilder .build(awsCredentials, documentServiceEndpoint); final AmazonCloudSearchDomain searchServiceClient = AmazonCloudSearchDomainClientBuilder.build( awsCredentials, searchServiceEndpoint); documentServiceClients.put(domainStatus.getDomainName(), documentServiceClient); searchServiceClients.put(domainStatus.getDomainName(), searchServiceClient); } } domainEndpointsCached = true; } } }

Target:
private void cacheDomainEndpoints() { if (!initialized) { throw new IllegalStateException("CloudSearchEngine not initialized"); } if (!domainEndpointsCached) { final Set<String> managedDomains = new HashSet<>(); for (final DocumentConfiguration documentConfiguration : documentConfigurations.values()) { final String domainName = documentConfigurationHolder.schemaName() + "-" + documentConfiguration.namespace(); managedDomains.add(domainName); } final DescribeDomainsRequest describeDomainsRequest = new DescribeDomainsRequest(); describeDomainsRequest.setDomainNames(managedDomains); final DescribeDomainsResult describeDomainsResult = cloudSearchClient .describeDomains(describeDomainsRequest); final List<DomainStatus> domainStatusList = describeDomainsResult.getDomainStatusList(); if (domainStatusList.size() != managedDomains.size()) { logger.info("Unable to cache CloudSearch document/search endpoints for: " + managedDomains); } else { for (final DomainStatus domainStatus : domainStatusList) { if (domainStatus.isCreated() && !domainStatus.isDeleted()) { final String documentServiceEndpoint = domainStatus.getDocService().getEndpoint(); final String searchServiceEndpoint = domainStatus.getSearchService().getEndpoint(); if (documentServiceEndpoint == null || searchServiceEndpoint == null) { domainEndpointsCached = false; return; } final AmazonCloudSearchDomain documentServiceClient = AmazonCloudSearchDomainClientBuilder .build(awsCredentials, documentServiceEndpoint); final AmazonCloudSearchDomain searchServiceClient = AmazonCloudSearchDomainClientBuilder.build( awsCredentials, searchServiceEndpoint); documentServiceClients.put(domainStatus.getDomainName(), documentServiceClient); searchServiceClients.put(domainStatus.getDomainName(), searchServiceClient); } } domainEndpointsCached = true; } } }