package liquibase.executor;

import liquibase.database.Database;
import liquibase.exception.UnexpectedLiquibaseException;
import liquibase.servicelocator.ServiceLocator;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class ExecutorService {

    private static ExecutorService instance = new ExecutorService();

    private Map<Database, Executor> executors = new ConcurrentHashMap<>();

    private ExecutorService() {
    }

    public static ExecutorService getInstance() {
        return instance;
    }

    public Executor getExecutor(Database database) {
        if (!executors.containsKey(database)) {
            try {
                Executor executor = (Executor) ServiceLocator.getInstance().newInstance(Executor.class);
                executor.setDatabase(database);
                executors.put(database, executor);
            } catch (Exception e) {
                throw new UnexpectedLiquibaseException(e);
            }
        }
        return executors.get(database);
    }

    public void setExecutor(Database database, Executor executor) {
        executors.put(database, executor);
    }

    public void clearExecutor(Database database) {
        executors.remove(database);
    }

    public void reset() {
        executors.clear();
    }
}

@@ -598,13 +598,15 @@
     
-if (!
+return 
 exec
@@ -617,17 +617,21 @@
 s.co
-ntainsKey
+mputeIfAbsent
 (dat
@@ -639,10 +639,15 @@
 base
-))
+, db -%3E
  %7B%0A 
@@ -806,23 +806,17 @@
 tabase(d
-atabase
+b
 );%0A     
@@ -826,39 +826,22 @@
         
-executors.put(database,
+return
  executo
@@ -837,25 +837,24 @@
 urn executor
-)
 ;%0A          
@@ -944,32 +944,32 @@
 ;%0A            %7D%0A
+
         %7D%0A      
@@ -965,46 +965,8 @@
    %7D
-%0A        return executors.get(database
 );%0A 

Use computeIfAbsent to avoid concurrency issues