<commit_before>package com.inepex.ineom.server;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.inepex.inei18n.shared.CurrentLang;
import com.inepex.ineom.shared.descriptor.DescriptorBase;
import com.inepex.ineom.shared.descriptor.ObjectDesc;
import com.inepex.ineom.shared.descriptor.fdesc.FDesc;
import com.inepex.ineom.shared.descriptorstore.ClientDescriptorStore;
import com.inepex.ineom.shared.descriptorstore.DescriptorStore;

public class MultiLangDescStore extends DescriptorStore {
	
	private static final Logger _logger = LoggerFactory.getLogger(MultiLangDescStore.class);
	
	private final Map<String, DescriptorStore> storeByLang = new HashMap<String, DescriptorStore>();
	private final Provider<CurrentLang> currLangProvider;
	private DescStoreCreator descStoreCreator;
	
	@Inject
	public MultiLangDescStore(Provider<CurrentLang> currLangProvider, DescStoreCreator descStoreCreator) {
		this.currLangProvider = currLangProvider;
		this.descStoreCreator=descStoreCreator;
	}
	
	public DescriptorStore get(String lang) {
		if (!storeByLang.containsKey(lang)){
			_logger.info("MultiDescStore has just created desc store for lang: {}", lang);
			ClientDescriptorStore localizedDescStore = descStoreCreator.createDescStore(lang);
			storeByLang.put(lang, localizedDescStore);
		}
		return storeByLang.get(lang);
	}
	
	public String currentLang() {
		try {
			return currLangProvider.get().getCurrentLang();
		} catch (Exception e) {<commit_msg>add syncronization to MultiLangDescStore<commit_after>package com.inepex.ineom.server;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.inepex.inei18n.shared.CurrentLang;
import com.inepex.ineom.shared.descriptor.DescriptorBase;
import com.inepex.ineom.shared.descriptor.ObjectDesc;
import com.inepex.ineom.shared.descriptor.fdesc.FDesc;
import com.inepex.ineom.shared.descriptorstore.ClientDescriptorStore;
import com.inepex.ineom.shared.descriptorstore.DescriptorStore;

public class MultiLangDescStore extends DescriptorStore {
	
	private static final Logger _logger = LoggerFactory.getLogger(MultiLangDescStore.class);
	
	private final Map<String, DescriptorStore> storeByLang = new HashMap<String, DescriptorStore>();
	private final Provider<CurrentLang> currLangProvider;
	private DescStoreCreator descStoreCreator;
	
	@Inject
	public MultiLangDescStore(Provider<CurrentLang> currLangProvider, DescStoreCreator descStoreCreator) {
		this.currLangProvider = currLangProvider;
		this.descStoreCreator=descStoreCreator;
	}
	
	public DescriptorStore get(String lang) {
		synchronized (storeByLang) {
			if (!storeByLang.containsKey(lang)){
				_logger.info("MultiDescStore has just created desc store for lang: {}", lang);
				ClientDescriptorStore localizedDescStore = descStoreCreator.createDescStore(lang);
				storeByLang.put(lang, localizedDescStore);
			}
			return storeByLang.get(lang);	
		}		
	}
	
	public String currentLang() {
		try {
			return currLangProvider.get().getCurrentLang();
		} catch (Exception e) {
{'fraction_non_alphanumeric': 0.09336162473476811, 'fraction_numerical': 0.002424977265838133, 'mean_word_length': 6.2210065645514225, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '1918718', 'n_tokens_mistral': 1050, 'n_tokens_neox': 990, 'n_words': 193}