<commit_before>package org.digidoc4j;

import java.lang.reflect.Field;
import java.util.concurrent.ExecutorService;

import org.digidoc4j.impl.ConfigurationSingeltonHolder;
import org.digidoc4j.impl.asic.tsl.LazyTslCertificateSource;
import org.digidoc4j.impl.asic.xades.validation.ThreadPoolManager;

import eu.europa.esig.dss.tsl.service.TSLValidationJob;

/**
 * Shutdown hook for clean shutdown. Please register this hook by Runtime.getRuntime().addShutdownHook(new
 * ShutdownHook()) when necessary. This hook works only for limited cases
 * <p>
 * Created by <NAME> (CGI Estonia)
 */

public class ShutdownHook extends Thread {

  @Override
  public void run() {
    this.shutdownDefaultExecutorService();
    if (ConfigurationSingeltonHolder.isInitialized()) {
      Configuration configuration = ConfigurationSingeltonHolder.getInstance();
      this.shutdownExecutorService(configuration);
      this.shutdownTSLValidationJob(configuration);
    }
  }

  /*<commit_msg>Javadoc amended<commit_after>package org.digidoc4j;

import java.lang.reflect.Field;
import java.util.concurrent.ExecutorService;

import org.digidoc4j.impl.ConfigurationSingeltonHolder;
import org.digidoc4j.impl.asic.tsl.LazyTslCertificateSource;
import org.digidoc4j.impl.asic.xades.validation.ThreadPoolManager;

import eu.europa.esig.dss.tsl.service.TSLValidationJob;

/**
 * Shutdown hook for clean shutdown. Please register this hook by Runtime.getRuntime().addShutdownHook(new
 * ShutdownHook()) when necessary. This hook works only for limited cases. NB! Currently in experimental status
 *
 * Created by <NAME> (CGI Estonia)
 */

public class ShutdownHook extends Thread {

  @Override
  public void run() {
    this.shutdownDefaultExecutorService();
    if (ConfigurationSingeltonHolder.isInitialized()) {
      Configuration configuration = ConfigurationSingeltonHolder.getInstance();
      this.shutdownExecutorService(configuration);
      this.shutdownTSLValidationJob(configuration);
    }
  }

  /*
{'fraction_non_alphanumeric': 0.09437751004016064, 'fraction_numerical': 0.004016064257028112, 'mean_word_length': 5.132307692307692, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5208088', 'n_tokens_mistral': 591, 'n_tokens_neox': 579, 'n_words': 121}