/*
 * Copyright © 2015-2018 Santer Reply S.p.A.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package it.reply.orchestrator.config;

import org.apache.ignite.Ignite;
import org.apache.ignite.IgniteCheckedException;
import org.apache.ignite.IgniteSpring;
import org.apache.ignite.configuration.IgniteConfiguration;
import org.apache.ignite.configuration.TransactionConfiguration;
import org.apache.ignite.logger.slf4j.Slf4jLogger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.jta.JtaTransactionManager;

@Configuration
public class IgniteConfig {

  /**
   * Generates a new IgniteConfiguration.
   * 
   * @return the generated IgniteConfiguration
   */
  @Bean
  public IgniteConfiguration igniteConfiguration(JtaTransactionManager transactionManager) {

    TransactionConfiguration txCfg = new TransactionConfiguration()
        .setTxManagerFactory(() -> transactionManager.getTransactionManager());

    return new IgniteConfiguration()
        .setGridLogger(new Slf4jLogger())
        .setClientMode(false)
        .setActiveOnStart(true)
        .setTransactionConfiguration(txCfg)
        .setMetricsLogFrequency(0);
  }

  /**
   * Generates a new Ignite instance.
   * 
   * @return the generated Ignite instance
   */
  @Bean(destroyMethod = "close")
  public Ignite ignite(ApplicationContext applicationContext,
      IgniteConfiguration igniteConfiguration) throws IgniteCheckedException {
    Ignite ignite = null;
    try {
      ignite = IgniteSpring.start(igniteConfiguration, applicationContext);
    } catch (Exception ex) {
      if (ignite != null) {
        ignite.close();
      }
      throw ex;
    }
    return ignite;
  }
}

@@ -2084,54 +2084,14 @@
     
-Ignite ignite = null;%0A    try %7B%0A      ignite =
+return
  Ign
@@ -2152,138 +2152,8 @@
 t);%0A
-    %7D catch (Exception ex) %7B%0A      if (ignite != null) %7B%0A        ignite.close();%0A      %7D%0A      throw ex;%0A    %7D%0A    return ignite;%0A
   %7D%0A

Remove redundant null check