Source:
<code>public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Args: confFile"); <START> return; <END> } Map<String, Object> conf = Utils.findAndReadConfigFile(args[0]); Configuration configuration = new Configuration(); configuration.zkHosts = getOrError(conf, "zookeeper.servers"); configuration.zkRoot = getOrError(conf, "zookeeper.root"); configuration.spoutId = getOrError(conf, "spout.id"); configuration.topic = getOrError(conf, "topic"); configuration.isWildcardTopic = getOrError(conf, "is.wildcard.topic"); configuration.kafkaBootstrapServers = getOrError(conf, "kafka.bootstrap.servers"); configuration.newSpoutConsumerGroup = getOrError(conf, "new.spout.consumer.group"); configuration.zkSessionTimeoutMs = getOrError(conf, "zookeeper.session.timeout.ms"); configuration.zkConnectionTimeoutMs = getOrError(conf, "zookeeper.connection.timeout.ms"); configuration.zkRetryTimes = getOrError(conf, "zookeeper.retry.times"); configuration.zkRetryIntervalMs = getOrError(conf, "zookeeper.retry.interval.ms"); Map<TopicPartition, OffsetAndMetadata> offsetsToCommit = getOffsetsToCommit(configuration); LOG.info("Migrating offsets {}", offsetsToCommit); Properties props = new Properties(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, configuration.kafkaBootstrapServers); props.put(ConsumerConfig.GROUP_ID_CONFIG, configuration.newSpoutConsumerGroup); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class); try (KafkaConsumer<?, ?> consumer = new KafkaConsumer<>(props)) { consumer.assign(offsetsToCommit.keySet()); consumer.commitSync(offsetsToCommit); } LOG.info("Migrated offsets to consumer group {}", offsetsToCommit, configuration.newSpoutConsumerGroup); }</code><technical_language>want exit explicit return code (noticing error): scripts leverages this module. for trident migration</technical_language>

Target:
public static void main(String[] args) throws Exception { if (args.length != 1) { System.err.println("Args: confFile"); System.exit(1); } Map<String, Object> conf = Utils.findAndReadConfigFile(args[0]); Configuration configuration = new Configuration(); configuration.zkHosts = MapUtil.getOrError(conf, "zookeeper.servers"); configuration.zkRoot = MapUtil.getOrError(conf, "zookeeper.root"); configuration.spoutId = MapUtil.getOrError(conf, "spout.id"); configuration.topic = MapUtil.getOrError(conf, "topic"); configuration.isWildcardTopic = MapUtil.getOrError(conf, "is.wildcard.topic"); configuration.kafkaBootstrapServers = MapUtil.getOrError(conf, "kafka.bootstrap.servers"); configuration.newSpoutConsumerGroup = MapUtil.getOrError(conf, "new.spout.consumer.group"); configuration.zkSessionTimeoutMs = MapUtil.getOrError(conf, "zookeeper.session.timeout.ms"); configuration.zkConnectionTimeoutMs = MapUtil.getOrError(conf, "zookeeper.connection.timeout.ms"); configuration.zkRetryTimes = MapUtil.getOrError(conf, "zookeeper.retry.times"); configuration.zkRetryIntervalMs = MapUtil.getOrError(conf, "zookeeper.retry.interval.ms"); Map<TopicPartition, OffsetAndMetadata> offsetsToCommit = getOffsetsToCommit(configuration); LOG.info("Migrating offsets {}", offsetsToCommit); Properties props = new Properties(); props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, configuration.kafkaBootstrapServers); props.put(ConsumerConfig.GROUP_ID_CONFIG, configuration.newSpoutConsumerGroup); props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class); props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, ByteArrayDeserializer.class); try (KafkaConsumer<?, ?> consumer = new KafkaConsumer<>(props)) { consumer.assign(offsetsToCommit.keySet()); consumer.commitSync(offsetsToCommit); } LOG.info("Migrated offsets to consumer group {}", offsetsToCommit, configuration.newSpoutConsumerGroup); }