Source:
<code><START> public TextIndexES(TextIndexConfig config, ESSettings esSettings) throws Exception{ <END> this.INDEX_NAME = esSettings.getIndexName(); this.docDef = config.getEntDef(); this.isMultilingual = config.isMultilingualSupport(); if (this.isMultilingual && config.getEntDef().getLangField() == null) { docDef.setLangField("lang"); } if(client == null) { LOGGER.debug("Initializing the Elastic Search Java Client with settings: " + esSettings); Settings settings = Settings.builder() .put(CLUSTER_NAME, esSettings.getClusterName()).build(); List<InetSocketTransportAddress> addresses = new ArrayList<>(); for(String host: esSettings.getHostToPortMapping().keySet()) { InetSocketTransportAddress addr = new InetSocketTransportAddress(InetAddress.getByName(host), esSettings.getHostToPortMapping().get(host)); addresses.add(addr); } InetSocketTransportAddress socketAddresses[] = new InetSocketTransportAddress[addresses.size()]; client = new PreBuiltTransportClient(settings).addTransportAddresses(addresses.toArray(socketAddresses)); LOGGER.debug("Successfully initialized the client"); } IndicesExistsResponse exists = client.admin().indices().exists(new IndicesExistsRequest(INDEX_NAME)).get(); if(!exists.isExists()) { Settings indexSettings = Settings.builder() .put(NUM_OF_SHARDS, esSettings.getShards()) .put(NUM_OF_REPLICAS, esSettings.getReplicas()) .build(); LOGGER.debug("Index with name " + INDEX_NAME + " does not exist yet. Creating one with settings: " + indexSettings.toString()); client.admin().indices().prepareCreate(INDEX_NAME).setSettings(indexSettings).get(); } }</code><technical_language>catch exceptions this class, if necessary throw a TextIndexException wraps original exception? TextIndexLucene it. need a throws Exception declaration passes responsibility of exception handling caller. (TextIndexException is a subclass of RuntimeException need a throws declaration)</technical_language>

Target:
public TextIndexES(TextIndexConfig config, ESSettings esSettings) { this.indexName = esSettings.getIndexName(); this.docDef = config.getEntDef(); docDef.setLangField("lang"); try { if(client == null) { LOGGER.debug("Initializing the Elastic Search Java Client with settings: " + esSettings); Settings settings = Settings.builder() .put(CLUSTER_NAME_PARAM, esSettings.getClusterName()).build(); List<InetSocketTransportAddress> addresses = new ArrayList<>(); for(String host: esSettings.getHostToPortMapping().keySet()) { InetSocketTransportAddress addr = new InetSocketTransportAddress(InetAddress.getByName(host), esSettings.getHostToPortMapping().get(host)); addresses.add(addr); } InetSocketTransportAddress socketAddresses[] = new InetSocketTransportAddress[addresses.size()]; client = new PreBuiltTransportClient(settings).addTransportAddresses(addresses.toArray(socketAddresses)); LOGGER.debug("Successfully initialized the client"); } IndicesExistsResponse exists = client.admin().indices().exists(new IndicesExistsRequest(indexName)).get(); if(!exists.isExists()) { Settings indexSettings = Settings.builder() .put(NUM_OF_SHARDS_PARAM, esSettings.getShards()) .put(NUM_OF_REPLICAS_PARAM, esSettings.getReplicas()) .build(); LOGGER.debug("Index with name " + indexName + " does not exist yet. Creating one with settings: " + indexSettings.toString()); client.admin().indices().prepareCreate(indexName).setSettings(indexSettings).get(); } }catch (Exception e) { throw new TextIndexException("Exception occurred while instantiating ElasticSearch Text Index", e); } }