Source:
public void doStart() throws Exception { super.doStart(); snsClient = configuration.getAmazonSNSClient() != null ? configuration.getAmazonSNSClient() : createSNSClient(); if (ObjectHelper.isNotEmpty(configuration.getAmazonSNSEndpoint())) { LOG.trace("Updating the SNS region with : " + configuration.getAmazonSNSEndpoint()); snsClient.setEndpoint(configuration.getAmazonSNSEndpoint()); } if (headerFilterStrategy == null) { headerFilterStrategy = new SqsHeaderFilterStrategy(); } if (configuration.getTopicArn() == null) { try { String nextToken = null; final String arnSuffix = ":" + configuration.getTopicName(); do { final ListTopicsResult response = snsClient.listTopics(nextToken); nextToken = response.getNextToken(); for (final Topic topic : response.getTopics()) { if (topic.getTopicArn().endsWith(arnSuffix)) { configuration.setTopicArn(topic.getTopicArn()); break; } } } while (nextToken != null); } catch (final AmazonServiceException ase) { LOG.trace("The list topics operation return the following error code {}", ase.getErrorCode()); throw ase; } } if (configuration.getTopicArn() == null) { CreateTopicRequest request = new CreateTopicRequest(configuration.getTopicName()); LOG.trace("Creating topic with request [{}]...", configuration.getTopicName(), request); CreateTopicResult result = snsClient.createTopic(request); configuration.setTopicArn(result.getTopicArn()); LOG.trace("Topic created with Amazon resource name: {}", configuration.getTopicArn()); } if (ObjectHelper.isNotEmpty(configuration.getPolicy())) { LOG.trace("Updating topic with policy [{}]", configuration.getTopicArn(), configuration.getPolicy()); snsClient.setTopicAttributes(new SetTopicAttributesRequest(configuration.getTopicArn(), "Policy", configuration.getPolicy())); LOG.trace("Topic policy updated"); } }

Target:
public void doStart() throws Exception { super.doStart(); snsClient = configuration.getAmazonSNSClient() != null ? configuration.getAmazonSNSClient() : createSNSClient(); if (ObjectHelper.isNotEmpty(configuration.getAmazonSNSEndpoint())) { LOG.trace("Updating the SNS region with : " + configuration.getAmazonSNSEndpoint()); snsClient.setEndpoint(configuration.getAmazonSNSEndpoint()); } if (headerFilterStrategy == null) { headerFilterStrategy = new SnsHeaderFilterStrategy(); } if (configuration.getTopicArn() == null) { try { String nextToken = null; final String arnSuffix = ":" + configuration.getTopicName(); do { final ListTopicsResult response = snsClient.listTopics(nextToken); nextToken = response.getNextToken(); for (final Topic topic : response.getTopics()) { if (topic.getTopicArn().endsWith(arnSuffix)) { configuration.setTopicArn(topic.getTopicArn()); break; } } } while (nextToken != null); } catch (final AmazonServiceException ase) { LOG.trace("The list topics operation return the following error code {}", ase.getErrorCode()); throw ase; } } if (configuration.getTopicArn() == null) { CreateTopicRequest request = new CreateTopicRequest(configuration.getTopicName()); LOG.trace("Creating topic with request [{}]...", configuration.getTopicName(), request); CreateTopicResult result = snsClient.createTopic(request); configuration.setTopicArn(result.getTopicArn()); LOG.trace("Topic created with Amazon resource name: {}", configuration.getTopicArn()); } if (ObjectHelper.isNotEmpty(configuration.getPolicy())) { LOG.trace("Updating topic with policy [{}]", configuration.getTopicArn(), configuration.getPolicy()); snsClient.setTopicAttributes(new SetTopicAttributesRequest(configuration.getTopicArn(), "Policy", configuration.getPolicy())); LOG.trace("Topic policy updated"); } }