<commit_before>package com.puresol.osgi;

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

import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;

/**
 * This manager keeps different named OSGi frameworks for central access. The
 * OSGi frameworks are only created and deleted. Opening and closing them is in
 * responsible to the creating application.
 * 
 * @author <NAME>
 * 
 */
public class OSGiFrameworkManager {

	private static final Map<String, OSGi> frameworks = new HashMap<String, OSGi>();

	public static OSGi getInstance(String name) {
		return frameworks.get(name);
	}

	public static OSGi createInstance(String name) {
		frameworks.put(name, new OSGi());
		return getInstance(name);
	}

	public static void deleteInstance(String name) {
		frameworks.get(name);
	}

	public static <T> List<T> getServices(String frameworkName,
			String serviceName, String filter, Class<T> clazz)
			throws InvalidSyntaxException {
		OSGi osgi = OSGiFrameworkManager.getInstance(frameworkName);
		BundleContext bundleContext = osgi.getContext();
		ServiceReference references[];
		references = bundleContext.getServiceReferences(serviceName, filter);
		List<T> services = new ArrayList<T>();
		for (ServiceReference reference : references) {
			@SuppressWarnings("unchecked")
			T t = (T) bundleContext.getService(reference);
			services.add(t);
		}
		return services;
	}
}<commit_msg>- fixed NullPointerException during service retrieval<commit_after>package com.puresol.osgi;

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

import org.osgi.framework.BundleContext;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;

/**
 * This manager keeps different named OSGi frameworks for central access. The
 * OSGi frameworks are only created and deleted. Opening and closing them is in
 * responsible to the creating application.
 * 
 * @author <NAME>
 * 
 */
public class OSGiFrameworkManager {

	private static final Map<String, OSGi> frameworks = new HashMap<String, OSGi>();

	public static OSGi getInstance(String name) {
		return frameworks.get(name);
	}

	public static OSGi createInstance(String name) {
		frameworks.put(name, new OSGi());
		return getInstance(name);
	}

	public static void deleteInstance(String name) {
		frameworks.get(name);
	}

	public static <T> List<T> getServices(String frameworkName,
			String serviceName, String filter, Class<T> clazz)
			throws InvalidSyntaxException {
		List<T> services = new ArrayList<T>();
		OSGi osgi = OSGiFrameworkManager.getInstance(frameworkName);
		if (osgi == null) {
			return services;
		}
		BundleContext bundleContext = osgi.getContext();
		if (bundleContext == null) {
			return services;
		}
		ServiceReference references[];
		references = bundleContext.getServiceReferences(serviceName, filter);
		if (references == null) {
			return services;
		}
		for (ServiceReference reference : references) {
			@SuppressWarnings("unchecked")
			T t = (T) bundleContext.getService(reference);
			services.add(t);
		}
		return services;
	}
}
{'fraction_non_alphanumeric': 0.10052745888923363, 'fraction_numerical': 0.0, 'mean_word_length': 4.926470588235294, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '3018885', 'n_tokens_mistral': 1017, 'n_tokens_neox': 917, 'n_words': 266}