<commit_before>/**
 * 
 */
package oci.locic;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

import oci.lib.ServiceNameEntry;

/**
 * The ServiceNameResolverThread class implements and worker thread for the providing client requests with the edge service ip address
 * 
 * @author marc
 */
public class ServiceNameResolverThread extends Thread {
	
	private ServerSocket	serverSocket	= null;
	
	
	public ServiceNameResolverThread(ServerSocket serverSocket) {
		this.serverSocket = serverSocket;
	}
	
	
	@Override 
	public void run() {
		
		Socket serviceResolverClient = null;
		
		try {
			
			while(true) {
				
				LocalOciCoordinator.LOGGER.info("Waiting for ServiceNameResolver registration");
				// blocking accept is ended when client connects or LOCIC main closes the server socket => exception
				serviceResolverClient = this.serverSocket.accept();
				LocalOciCoordinator.LOGGER.info("ServiceNameResolver client connected");

				// create object streams (later UDP set/get implementation)
				ObjectInputStream	ois = new ObjectInputStream(serviceResolverClient.getInputStream());
				ObjectOutputStream	oos = new ObjectOutputStream(serviceResolverClient.getOutputStream());
				
				ServiceNameEntry serviceNameEntry = (ServiceNameEntry) ois.readObject();
				for(int i = 0; i < LocalOciCoordinator.serviceList.size(); i++) {
					if(LocalOciCoordinator.serviceList.get(i).getServiceName().equals(serviceNameEntry.getServiceName())) {
						
						// TODO how to handle duplicated entries - currently client receives all matching service entries
						if(serviceNameEntry.getIpAddress() == null) { // not necessary safety check<commit_msg>null pointer exception patch<commit_after>/**
 * 
 */
package oci.locic;

import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.ServerSocket;
import java.net.Socket;

import oci.lib.ServiceNameEntry;

/**
 * The ServiceNameResolverThread class implements and worker thread for the providing client requests with the edge service ip address
 * 
 * @author marc
 */
public class ServiceNameResolverThread extends Thread {
	
	private ServerSocket	serverSocket	= null;
	
	
	public ServiceNameResolverThread(ServerSocket serverSocket) {
		this.serverSocket = serverSocket;
	}
	
	
	@Override 
	public void run() {
		
		Socket serviceResolverClient = null;
		
		try {
			
			while(true) {
				
				LocalOciCoordinator.LOGGER.info("Waiting for ServiceNameResolver registration");
				// blocking accept is ended when client connects or LOCIC main closes the server socket => exception
				serviceResolverClient = this.serverSocket.accept();
				LocalOciCoordinator.LOGGER.info("ServiceNameResolver client connected");

				// create object streams (later UDP set/get implementation)
				ObjectInputStream	ois = new ObjectInputStream(serviceResolverClient.getInputStream());
				ObjectOutputStream	oos = new ObjectOutputStream(serviceResolverClient.getOutputStream());
				
				ServiceNameEntry serviceNameEntry = (ServiceNameEntry) ois.readObject();
				if(serviceNameEntry == null) break;
				for(int i = 0; i < LocalOciCoordinator.serviceList.size(); i++) {
					if(LocalOciCoordinator.serviceList.get(i).getServiceName().equals(serviceNameEntry.getServiceName())) {
						
						// TODO how to handle duplicated entries - currently client receives all matching service entries
						if(serviceNameEntry.getIpAddress() == null) { // not necessary safety check
{'fraction_non_alphanumeric': 0.08511243951038998, 'fraction_numerical': 0.000569313976658127, 'mean_word_length': 4.456521739130435, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1375874', 'n_tokens_mistral': 1055, 'n_tokens_neox': 879, 'n_words': 255}