<commit_before>package ua.com.fielden.platform.domaintree.impl;

import java.util.concurrent.ConcurrentHashMap;

import ua.com.fielden.platform.domaintree.IGlobalDomainTreeManager;
import ua.com.fielden.platform.domaintree.IServerGlobalDomainTreeManager;

import com.google.inject.Inject;
import com.google.inject.Provider;

/**
 * The server global domain tree manager implementation.
 *
 * @author TG Team
 *
 */
public class ServerGlobalDomainTreeManager implements IServerGlobalDomainTreeManager {
    private final Provider<IGlobalDomainTreeManager> gdtmProvider;
    private final ConcurrentHashMap<String, IGlobalDomainTreeManager> managersByUser;

    @Inject
    public ServerGlobalDomainTreeManager(final Provider<IGlobalDomainTreeManager> gdtmProvider) {
        this.gdtmProvider = gdtmProvider;
        this.managersByUser = new ConcurrentHashMap<>();
    }

    @Override
    public IGlobalDomainTreeManager get(final String username) {
        managersByUser.putIfAbsent(username, gdtmProvider.get());
        return managersByUser.get(username);
    }
}<commit_msg>Fixed initialisation of user-based global manager by using lazy initialiser only where not initialised yet.<commit_after>package ua.com.fielden.platform.domaintree.impl;

import java.util.concurrent.ConcurrentHashMap;

import ua.com.fielden.platform.domaintree.IGlobalDomainTreeManager;
import ua.com.fielden.platform.domaintree.IServerGlobalDomainTreeManager;

import com.google.inject.Inject;
import com.google.inject.Provider;

/**
 * The server global domain tree manager implementation.
 *
 * @author TG Team
 *
 */
public class ServerGlobalDomainTreeManager implements IServerGlobalDomainTreeManager {
    private final Provider<IGlobalDomainTreeManager> gdtmProvider;
    private final ConcurrentHashMap<String, IGlobalDomainTreeManager> managersByUser;

    @Inject
    public ServerGlobalDomainTreeManager(final Provider<IGlobalDomainTreeManager> gdtmProvider) {
        this.gdtmProvider = gdtmProvider;
        this.managersByUser = new ConcurrentHashMap<>();
    }

    @Override
    public IGlobalDomainTreeManager get(final String username) {
        // lazy initialisation using computeIfAbsent and 'name -> gdtmProvider.get()' is required not to reinitialise gdtm every time after putting it into concurrent hash map
        return managersByUser.computeIfAbsent(username, name -> gdtmProvider.get());
    }
}
{'fraction_non_alphanumeric': 0.07605985037406483, 'fraction_numerical': 0.0, 'mean_word_length': 5.047738693467337, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4745947', 'n_tokens_mistral': 667, 'n_tokens_neox': 663, 'n_words': 148}